3 replies
by congero Accepted solution
by tony hopkinson Accepted solution
some thing like
Declare csr_Products cursor For (insert your query here)
Declare @Product_ID int
open csr_Products
Fetch From csr_Products into @Product_ID
While @@Fetch_Status = 0
Begin
Exec myProdSP @Product_ID
Fetch Next From csr_Products into @Product_ID
end
close csr_Products
deallocate csr_Products
NB optimisation for cursors is usually poor, definitely is in SQL Server, so if you are going to make frequent use of this technique be prepared for some performance losses and extra locking issues. For one off, admin and out of hours type stuff though, it's a goer.
You can add some modifiers when you declare the cursor such as forward only read ... which may be worth the effort for a bit more performance.
by aloksaxena01 Accepted solution
This discussion is closed to new replies.
Trending Networks posts
Sort by Trending