Skip to content
Advertisement

Simple check for SELECT query empty result

Can anyone point out how to check if a select query returns non empty result set?

For example I have next query:

Should I do something like next:

to test if result set is not empty?

Advertisement

Answer

Use @@ROWCOUNT:

According to SQL Server Books Online:

Returns the number of rows affected by the last statement. If the number of rows is more than 2 billion, use ROWCOUNT_BIG.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement