Monday, 21 June 2021

Check the row count in SQL dynamic query

 Here I am going to explain how to check the row count in SQL dynamic query


DECLARE @query  nvarchar(1000) = 'Select * from student',
        @cnt int

EXEC Sp_executesql @query

SELECT @cnt = @@ROWCOUNT
IF @cnt > 0
BEGIN Select 1 END

No comments:

Post a Comment