Search code examples
sql-serverlinked-server

What does SSMS use to create a linked SQL Server by name?


We have several SQL servers set up in my workplace that are all linked to each other and we make use of 4-part DB names in a lot of our code. We are considering moving some of our databases from one server to another and are assessing the impact on our code, however no one here seems to know beyond the Linked Server Name what protocol is used in the [server] portion of the 4pt DB name [server].[database].[dbo].[table]. Is the [server] portion a WINS entry, is it simply DNS, or is SQL Server doing something clever on it's own to get there?

If it's DNS, it will be simple enough to move the DB's (minimal code changes), but anything else and we may have to reconsider our strategy.


Solution

  • server is just a symbolic name, the datasrc is what really matters.

    Suppose you have a linked server created like this:

    EXEC master.dbo.sp_addlinkedserver @server = N'TEST', @srvproduct=N'', @provider=N'SQLNCLI', @datasrc=N'server2008r2'
    

    and the queries select from TEST.database.schema.table. Recreate the linked server with different @datasrc and it will still work, but this time it would read data from a different physical server (as long as the data is there and the security is set up right).