How to reference a sql server with a backslash (\) in its name?

前端 未结 3 1900
说谎
说谎 2021-02-13 04:48

Givens:

  • One SQL Server is named: DevServerA
  • Another is named: DevServerB\\2K5

Problem:

3条回答
  •  萌比男神i
    2021-02-13 05:18

    In 4 part names, the first part if the name of a linked server (ie. a metadata object), not the name of a server (ie. a host name). So you can name your linked server FOO and have him point at the host BAR, or at the instance FOO\BAR. And even if you name the linked server object to contain a slash, you can still use it in a multi-part name by simply quoting the name:

    SELECT TOP 1 *  
    FROM [DevServerB\2K5].master.sys.tables
    

提交回复
热议问题