Hi Anand,>>Here I am using a cursor, is it safe and do I have an alternative for the cursors in this caseThere is almost always a better, set-based alternative to using a cursor but it is impossible to be specific without more information from you. I suggest you register with sqlteam.com so you can respond to posts, then respond to this post with the entire SP code (that uses the cursor).Here is a (very simple) example of replacing a cursor with a set-based solution:--cursordeclare @pk int, @col1 intdeclare crs cursor for select pk, col1 from myTable where dtCol = 'myDate'open crsfetch next from crs into @pk, @col1while @@fetch_status = 0begin update myOtherTable set col1 = @col1 where pk = @pk fetch next from crs into @pk, @col1endclose crsdeallocate crs--set basedupdate mt set mt.col1 = mot.col1from myTable mtjoin myOtherTable mot on mot.pk = mt.pkwhere dtCol = 'myDate'
Be One with the OptimizerTG