7
Answers

Stored procedure - Only return if rows > 0

Photo of Thomas

Thomas

7y
287
1
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
 

Answers (7)

0
Photo of Vulpes
NA 98.3k 1.5m 13y
None of those functions are anything to do with ASP.NET as such though they can be called from it (using the Platform Invoke mechanism in the case of the first two).

Briefly:

* LoadLibrary is an unmanaged function which loads a dll into a process's address space.

* CoCreateInstance is an unmanaged funmction which creates a COM object using its Class Id (CLSID).

* CreateObject is a VB library function which creates a COM object using its Program Id (ProgID).

* Assembly.Load is a .NET method which loads an assembly at runtime.