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

前端 未结 3 595
独厮守ぢ
独厮守ぢ 2021-02-13 04:33

Givens:

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

Problem:

3条回答
  •  难免孤独
    2021-02-13 05:30

    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
    

提交回复
热议问题