Tuesday, April 19, 2005

cool stuff - stored proc resultset queries

This command allows you to link to the local SQL Server & select individual columns from a stored procedure

sp_addlinkedserver @server = 'LOCALSERVER', @srvproduct = '', @provider = 'SQLOLEDB', @datasrc = @@servername
GO

select * from openquery(localserver,'exec mystoredproc')
GO

Great for comparing the results of 2 stored procedures, or doing union queries against multiple stored procedures without temp tables.

http://www.sommarskog.se/share_data.html

No comments: