How do I connect to a named instance of a linked SQL server.
如何连接到链接SQL Server的命名实例。
If its not linked, I would do the following:
如果没有链接,我会做以下事情:
ServerName.DatabaseName.dbo.TableName
If it is linked, I would assume the following:
如果它是链接的,我会假设如下:
ServerName\InstanceName.DatabaseName.dbo.TableName
but SQL doesn't like the "\"
但SQL不喜欢“\”
What is the correct syntax
什么是正确的语法
3 个解决方案
#2
the correct syntax is [ServerName\InstanceName].DatabaseName.dbo.TableName
.
正确的语法是[ServerName \ InstanceName] .DatabaseName.dbo.TableName。
#3
If you are using the default instance, you don't need to specify the instance name.
如果您使用的是默认实例,则无需指定实例名称。
Example using the default instance: [MyServer].[MyDatabase].[MySchema].[MyTable]
使用默认实例的示例:[MyServer]。[MyDatabase]。[MySchema]。[MyTable]
NB: If you don't know your schema name, give [dbo] a try, since that is the default schema.
注意:如果您不知道您的模式名称,请尝试[dbo],因为这是默认模式。
So something like this should work for you
所以这样的事情对你有用
SELECT *
FROM [MyTable] t
INNER JOIN [MyLinkedServer].[MyLinkedDatabase].[MyLinkedSchema].[MyLinkedTable] lt ON lt.Id = t.Id
#1
#2
the correct syntax is [ServerName\InstanceName].DatabaseName.dbo.TableName
.
正确的语法是[ServerName \ InstanceName] .DatabaseName.dbo.TableName。
#3
If you are using the default instance, you don't need to specify the instance name.
如果您使用的是默认实例,则无需指定实例名称。
Example using the default instance: [MyServer].[MyDatabase].[MySchema].[MyTable]
使用默认实例的示例:[MyServer]。[MyDatabase]。[MySchema]。[MyTable]
NB: If you don't know your schema name, give [dbo] a try, since that is the default schema.
注意:如果您不知道您的模式名称,请尝试[dbo],因为这是默认模式。
So something like this should work for you
所以这样的事情对你有用
SELECT *
FROM [MyTable] t
INNER JOIN [MyLinkedServer].[MyLinkedDatabase].[MyLinkedSchema].[MyLinkedTable] lt ON lt.Id = t.Id