Monday, January 24, 2011

Access Remote sql server’s database table

For accessing Remote SqlServer we need to add remote sqlserver to sys.servers

Syntax for accessing Remote SqlServer: 

select * from Servername.Databasename.dbo.Tablename

it will give following error

“Msg 7202, Level 11, State 2, Line 1
Could not find server 'ServerName' in sysservers. Execute sp_addlinkedserver to add the server to sysservers.

The syntax to add a remote sql server to sys.servers is:

execute sp_addlinkedserver sqlserverName
If you add your remote server to sys.servers then you can access remote server using following simple query.

select * from servername.databasename.dbo.tablename

If you try to access remote SqlServer without adding remote server to sys.servers

No comments:

Post a Comment