Can anyone point out how to check if a select query returns non empty result set?
For example I have next query:
SELECT * FROM service s WHERE s.service_id = ?;
Should I do something like next:
ISNULL(SELECT * FROM service s WHERE s.service_id = ?)
to test if result set is not empty?
I agree with Ed B. You should use EXISTS method but a more efficient way to do this is:
HTH
well there is a way to do it a little more code but really effective
Use @@ROWCOUNT:
According to SQL Server Books Online:
You can do it in a number of ways.
Or you can use
IF NOT EXISTS , @@ROW_COUNT
likeIn my sql use information function
it will return the no. of rows returned by select query.