user1141584
user1141584

Reputation: 619

Stored Procedure Conditions

I'm getting a bit clueless about this thing in SQL Server. I m not sure whether this is possible or not.

Well, all I m looking for is as below

Something like

IF EXEC (@temp) THEN 'The results are present'
ELSE ''
END IF

Any input on this , would be helpful !!!

Thanks !!!

Upvotes: 0

Views: 220

Answers (1)

mangeshkt
mangeshkt

Reputation: 3116

Take a temporary table, and insert whatever data the stored procedure returns into it. This way you will end up writing

INSERT INTO @tempTable(col1,col2) SELECT val1,val2 FROM table1

instead of only

SELECT val1,val2 FROM table1

at the end just check for no of records in temp table

if exists(select * from @temptable)
 print'stored procedure returned some data'
else
 print'stored procedure did not return data'

Upvotes: 1

Related Questions