I have a stored procedure which returns a Dataset(Table)
. How can I use the result of this stored procedure in a SELECT
statement?
I need s
The answer of Marcelo Cantos is the best one. Also for distributed queries you can use the following script:
USE [master]
sp_configure 'Ad Hoc Distributed Queries', 1
RECONFIGURE
USE [YourDB]
SELECT *
FROM OPENROWSET('SQLNCLI', 'Server=YourServer ;Trusted_Connection=yes;',
'EXEC YourDB.YourSchema.YourSP ''YourParameters1'', YourParameters2') AS c
INNER JOIN YourTableOrView ap ON ap.YourPK = c.YourFK
http://www.kodyaz.com/articles/how-to-sql-select-from-stored-procedure-using-openquery-openrowset.aspx