Reputation: 79
I am doing a project using sql cursors, for one cursor i want to loop through a dataset of Company ids.
How would you use logic such as
How would you perform this is a while loop of a cursor.
I have been looking at this tutorial
Upvotes: 0
Views: 381
Reputation: 1611
For one it's always recommended in all cases to absolutely avoid the use of cursors. They are known to experience very poor performance issues and 95% of the time it's possible to perform the necessary function with set-based logic.
To solve this particular problem using psuedo would look something like this:
INSERT INTO DestinationTable
SELECT CompanyID, SomeDataColumn
FROM SourceTable
WHERE ISNULL(CompanyID, 0) = 0
Upvotes: 2