If I have a SQL script stored in a variable like this:
DECLARE @SQL VARCHAR(MAX) = 'SELECT * FROM Employees WHERE Age > 80'
How can I tell if @SQL would return any rows if I were to run it?
In effect this:
IF EXISTS(@SQL) print 'yes, there are rows' -- Dummy code -- does not work!
I would like to try this without having to run the script in @SQL, insert that into a table and them count the rows.