Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server : how to get specific column from stored procedure without modifying it

Here is the sample stored procedure

DECLARE @ReturnTable TABLE (DateTime DATETIME,      
                            WrongUSSD VARCHAR(30),
                            AllMSISDN INT,      
                            UniqueMSISDN INT,   
                            SubscriptionActivated INT)

SELECT * 
FROM @ReturnTable

Modification in stored procedure is not allowed, I just need specific column form this procedure by select statement.

I have tried this

select WrongUSSD 
FROM openrowset('MSDASQL', 'Driver={SQL SERVER}; Server=server_name;UID=user; PWD=pass;Trusted_Connection=yes;', 'EXEC [DatabaseName].[dbo].[ProcedureName] "2016-01-01","2016-04-01"') as a

This method doesn't work if the is link server exists in stored procedure

Is there any other method?? Please help

like image 921
kiran mulmi Avatar asked Nov 09 '22 15:11

kiran mulmi


1 Answers

Using temp table:

INSERT INTO #TempTable
EXEC [dbo].[ProcedureName]

SELECT WrongUSSD
FROM #TempTable
like image 90
Backs Avatar answered Nov 14 '22 22:11

Backs