Using the result of an Stored procedure in a Select statement

后端 未结 5 560
暗喜
暗喜 2021-01-20 15:27

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

5条回答
  •  抹茶落季
    2021-01-20 15:47

    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

提交回复
热议问题