Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
BuddyRam
Starting Member
17 Posts |
Posted - 2007-07-03 : 05:27:16
|
| Hello,I have to update a table while looping through it records based on condition..my procedure is as foloows:create procedure sample_update asdeclare @id intdeclare sel_publisher cursor forselect publisher_id from tblpublishers open sel_publisherfetch next from sel_publisher into @idWHILE @@FETCH_STATUS = 0BEGIN --if @id > 30 then --My update statementlike-- update tblpublishers set newid = 31 where where id = @id --end ifFETCH NEXT FROM Employee_Cursor into @idENDclose sel_publisherdeallocate end sample_updateI have to put my update statement based on if condition , howcan i do it???ThanksCheersRam |
|
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2007-07-03 : 05:38:18
|
Ditch the cursor.UPDATE tblpublishersSET [newid] = 31WHERE publisher_id > 30 |
 |
|
|
|
|
|