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 |
|
abarsami
Yak Posting Veteran
68 Posts |
Posted - 2001-06-21 : 15:45:26
|
| I tried it with a cursor first and it took way too long.Now I did it this way and the problem is it doesn't go to the next record. How can I get it to loop, without using a cursor.Thanksdeclare @mc_code varchar(20)declare @mg_code varchar(20)declare @date datetimedeclare @zcode varchar(20)declare @counter intdeclare @max intset nocount onselect @counter=0select @mc_code=d.mc_code, @mg_code=ms.mg_code, @z_code=c.z_code, @date=c.datefrom TableC c join tableD d on(c.category_no=d.category_no) join MC mc on(d.mc_code=mc.mc_code) join MS ms on(mc.ms_code=ms.ms_code)select @max = @@rowcountWhile @counter < @max Begin Update TableC set mc_code = @mc_code where date= @date and z_code = @z_code Update TableC set mg_code = @mg_code where date = @date and z_code = @z_code select @counter = @counter + 1 End |
|
|
|
|
|