我在使用链接服务器的DB加入本地数据库时遇到任何问题.
我的查询:
SELECT [LocalDatabase].[dbo].[Record].[Project_ID],[LinkedServer].[Reporting].[dbo].[Active].[Name] FROM [LocalDatabase].[dbo].[Record] inner join [LinkedServer].[Reporting].[dbo].[Active] ON [LocalDatabase].[dbo].[Record].[Project_ID] = [LinkedServer].[Reporting].[dbo].[Active].[Delivery_Number]
错误:
Msg 4104,Level 16,State 1,Line 9 The multi-part identifier "LinkedServer.Reporting.dbo.Active.Delivery_Number" could not be bound. Msg 4104,Line 5 The multi-part identifier "LinkedServer.Reporting.dbo.Active.Name" could not be bound.
我猜我的语法不正确,但我无法修复它.
有人可以建议一个解决方案?
解决方法
尝试使用表别名来写这个:
SELECT r.[Project_ID],a.[Name] FROM [LocalDatabase].[dbo].[Record] r inner join [LinkedServer].[Reporting].[dbo].[Active] a ON r.[Project_ID] = a.[Delivery_Number];