Share via


Executing dynamic SQL scripts on remote SQL Server with EXEC AT statement

Executing dynamic SQL scripts on remote SQL Server with EXEC AT statement

With SQL Server 2000, we had OPENQUERY and OPENROWSET to execute a pass-through query on the specified server, but it has several inherent limitations. Starting with SQL Server 2005 we have another more elegant way using "EXEC AT" to execute a pass-through query on the specified linked server which also addresses several shortcomings of OPENQUERY and OPENROWSET table functions. This article talks about this new way of executing dynamic SQL scripts on the remote server in SQL Server 2005 and 2008.