Created
January 8, 2010 18:52
-
-
Save softcraft-development/272281 to your computer and use it in GitHub Desktop.
Show the remote server data source for synonyms targeting linked servers in SQL Server 2005
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
sk.name as LocalSchemaName, | |
sn.name as SynonymName, | |
sn.base_object_name as FullTargetName, | |
substring( sn.base_object_name, 2, charindex(']', sn.base_object_name) - 2) as LinkedServerName, | |
sv.data_source as RemoteServerName, | |
substring( | |
sn.base_object_name, | |
charindex('[', sn.base_object_name, 2) + 1, | |
charindex( | |
']', | |
sn.base_object_name, | |
charindex('[', sn.base_object_name, 2) | |
) - charindex('[', sn.base_object_name, 2) - 1 | |
) as RemoteDatabaseName | |
from sys.synonyms sn | |
inner join sys.schemas sk | |
on sn.schema_id = sk.schema_id | |
inner join sys.servers sv | |
on sv.name = substring( sn.base_object_name, 2, charindex(']', sn.base_object_name) - 2) | |
order by sk.name, sn.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment