views:

393

answers:

2

I added a linked server,and it is showing in the linked server list,but when i'm quering it's throwing an error with the db server name.

*EXEC sp_helpserver*

EXEC sp_addlinkedserver 'aa-db-dev01'

Select * from openquery('aa-db-dev01','Select * from TestDB.dbo.users')

Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'aa-db-dev01'.

Please Help Thanks Renju

A: 
SELECT * FROM [server].[database].[scheme].[table]

this works for me

Andreas Niedermair
+2  A: 

You need to remove the quote marks from around the name of the linked server. It should be like this:

Select * from openquery(aa-db-dev01,'Select * from TestDB.dbo.users')

BTB