what i am doing is i am going over the table on depending on its data i set 1 of the columns (say XXX) to 1 (the default is 0)later on the rows with the XXX=1 i am using to make diffrent thing like export to text files and so on.my code :DECLARE cursor_RB CURSOR SCROLL_LOCKS FOR SELECT Company, Application, Command, EVT , CASE WHEN LEFT(Rtci, 6) = '+97250' THEN 0 ELSE 1 END AS TIT, ICD, CASE WHEN JLMB IS NULL THEN 0 ELSE 1 END as ISTF,ID ,Srde,Rtci,StartDate FROM M2007 LEFT OUTER JOIN ORDER BY M2007.SD ASC FOR UPDATE of is4BillingOPEN cursor_RBFETCH NEXT FROM cursor_RB INTO @Company,@Application,@DC,@VET,@IT,@ICGD, @ISF,@ID,@rSdr,@Rtci,@StartDate2WHILE @@FETCH_STATUS = 0BEGIN SET @IDD=0 SELECT @IDD=ID from CM2007 WHERE isUsed=0 AND Srde=@rSdr AND Rtci=@Rtci AND (StartDate<=@StartDate2+@INTERVAL_TIME) AND (StartDate-@StartDate2>=0) --print @IDD if @IDD>0 begin begin Tran UPDATE CM2007 SET isUsed=1 WHERE ID=@IDD Commit end set @SID=0 select @SID= case when Lower(@Company)='fne1' AND @IT=1 then 12 when @IT=1 AND @ISF=1 then 6 when Lower(@Application)='la' then case when Lower(@Company)='pt' then 16 when @ISF=1 then 17 when @DC='sgt' then 9 when @DC='sct' then 10 when @DC='semt' then 13 when @DC='sdkt' then 14 when @DC='ssmt' then 19 when @DC='seif' then 20 when @DC='somt' then 21 ELSE 7 end end if @SID<>0 AND @SID is Not Null AND @IDD>0 begin INSERT INTO M2007_Result (id) VALUES(@ID) exec ( @sqInsert) EndFETCH NEXT FROM cursor_RB INTO @Company,@Application,@DC,@VET,@IT,@ICGD, @ISF,@ID,@rSdr,@Rtci,@StartDate2ENDCLOSE cursor_RBDEALLOCATE cursor_RB
what do you mean by "set based "?can you explain how to do it instead of using cursor's?thnaks i nadvancepelegIsrael -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)