Suppose I have a query stored in a variable like this (it\'s actually dynamically populated and more complex, but this is for demonstration purposes):
DECLAR
Try Executing the Dynamic query and use @@RowCount to find the existence of rows.
Dynamic query
@@RowCount
DECLARE @Query NVARCHAR(1000) = 'SELECT * FROM [dbo].[Mytable]', @rowcnt INT EXEC Sp_executesql @query SELECT @rowcnt = @@ROWCOUNT IF @rowcnt > 0 BEGIN PRINT 'row present' END