I'm looking to see if anyone can suggest an alternative to Cursors? The scenario: each day we perform a table transfer from our production DB to another SQL Server. This backup will then get transferred to a SAS server, however before I make it available to the SAS users I have to perform a fairly large calculation on each row within the table.
The table has about 100k rows so to run a sp against each row I'm having to use a cursor which you can imagine is taking a ridiculous amount of time.
All suggestions welcome! I've posted my cursor code however it's pretty standard.
Many thanks
Nick
The table has about 100k rows so to run a sp against each row I'm having to use a cursor which you can imagine is taking a ridiculous amount of time.
All suggestions welcome! I've posted my cursor code however it's pretty standard.
Code:
SET NOCOUNT ON
DECLARE @SecurityID objectId
DECLARE Security CURSOR FOR
SELECT ID
FROM SecurityIncGrossValue
OPEN Security
FETCH Security into @SecurityID
WHILE @@fetch_status = 0
BEGIN
EXEC sp_UpdateSecurityGrossValue @SecurityID
FETCH Security into @SecurityID
END
CLOSE Security
DEALLOCATE Security
RETURN
Many thanks
Nick