SQLServer - Test the result of a stored procedure

Posted by Melursus on Stack Overflow See other posts from Stack Overflow or by Melursus
Published on 2010-05-31T13:41:31Z Indexed on 2010/05/31 13:42 UTC
Read the original article Hit count: 220

In Microsoft SQLServer, it is possible to test the result of a stored procedure to know if the result return rows or nothing ?

Example :

EXEC _sp_MySp 1, 2, 3

IF @@ROWCOUNT = 0
BEGIN
    PRINT('Empty')
END
ELSE
BEGIN
    PRINT(@@ROWCOUNT)
END

But @@ROWCOUNT always return 0 so maybe is there another way of doing this ?

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2008