在sql2005中execute 提供了一个 AT参数,用来执行在link Server上的sql 语句,
Example:
EXECUTE sp_addlinkedserver @server='LocalLinkedServer', @srvproduct='',
@provider='SQLOLEDB', @datasrc='localhost'
EXECUTE sp_serveroption 'LocalLinkedServer','RPC OUT',True
EXECUTE('SELECT * FROM AdventureWorks.Production.Culture') AT LocalLinkedServer
EXECUTE sp_dropserver LocalLinkedServer
@provider='SQLOLEDB', @datasrc='localhost'
EXECUTE sp_serveroption 'LocalLinkedServer','RPC OUT',True
EXECUTE('SELECT * FROM AdventureWorks.Production.Culture') AT LocalLinkedServer
EXECUTE sp_dropserver LocalLinkedServer
当然用另外一个命令sp_executesql,也可以执行在link Server上的sql 语句:
EXECUTE ourLinkedServer.master.dbo.sp_executesql
@statement = N'SELECT * FROM AdventureWorks.Production.Culture'
@statement = N'SELECT * FROM AdventureWorks.Production.Culture'