I have to make a large number of updates (about 29k) so I generated teh update statements into a table and am trying to sue sp_executesql to run them. Here is my code:
Declare @.SQLState NVARCHAR(500)
Declare Code Cursor
for
select SQLState from updates
open Code
FETCH NEXT FROM Code
into @.SQLState
While @.@.fetch_Status = 0
Begin
Exec sp_executesql @.SQLState
FETCH NEXT FROM Code
END
CLOSE Code
DEALLOCATE Code
IT appears to run succesfully, but the updates never happen - I get the following results for each update line:
UPDATE REEmployeeEvent SET UpdatedByEmployeeID= '00013' Where UpdatedByEmployeeID='00279'
(1 row(s) affected)
(0 row(s) affected)
Any ideas what I am doing wrong?
BTW - If I run the statements manually, they do work.
Thanks for any help!is there any particular reason why you want to use such a non-standard method to execute a script?
Why not execute dump them to a file, and execute the file as a single batch? At least that way you could visually inspect the scripts for correctness.
What you are trying to do here seems risky at best.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment