Hi all. I have this stored procedure which executes a lot of sql queries and returns the results. How do i go about returning only the results from the queries that returns rows?
BEGIN
DECLARE @Query varchar(4000)
DECLARE cur CURSOR FOR SELECT SQLSyntax FROM tblChecks
OPEN cur
FETCH NEXT FROM cur INTO @Query
WHILE @@FETCH_STATUS = 0 BEGIN
EXEC (@Query)
FETCH NEXT FROM cur INTO @Query
END
CLOSE cur
DEALLOCATE cur
END

Abhilash J ARank #1,243 · 1.4K reputationPosted Jun 22, 2017, 8:45 AM EDT
Nilesh ShahRank #42 · 34.2K reputationPosted Jun 22, 2017, 7:16 AM EDT
Rajkiran SwainRank #165 · 14.4K reputationPosted Jun 22, 2017, 8:16 AM EDT
Abhilash J ARank #1,243 · 1.4K reputationPosted Jun 22, 2017, 8:39 AM EDT
Abhilash J ARank #1,243 · 1.4K reputationPosted Jun 22, 2017, 8:42 AM EDT
Thomas35 reputationPosted Jun 22, 2017, 8:42 AM EDT
Abhilash J ARank #1,243 · 1.4K reputationPosted Jun 22, 2017, 7:39 PM EDT