Hi Fellow Code WarriorsI was just wondering if you guys can help me optomise the following cursor - It's running Error-Free but a bit slow"a BIT slow" - hehehehehehe funny - bit slow?Enough jokes!Cursor:Declare @Enterprise varchar(10) , @Activity Varchar(50) , @Var Varchar(15) , @Tax varchar(15) , @Vat Varchar(10) , @sql NvarChar(400)use NADSet NoCount On/*if 'Enterprise_History' in ( Select name from sysobjects ) Begin Drop Table Enterprise_History endCreate Table Enterprise_History( Enterprise_Nbr Varchar(10) Not Null , Vat_Nbr Varchar(10) , Tax_NBr varchar(10) , Birt Varchar(50) , Acti Varchar(50) , Ceas Varchar(50) , Deac Varchar(50) , Unknown Varchar(50))*/Declare EntCur Cursor forSelect Distinct (Stat_Unit_Code)from bf..History_Detail as DWhere not exists ( Select Enterprise_Nbr from Enterprise_history as H where D.Stat_Unit_Code = H.Enterprise_Nbr )Open EntCurFetch Next From EntCur Into @EnterpriseWhile @@fetch_status=0 Begin-- if (-- Select Count(Enterprise_Nbr)-- from Enterprise_History-- Where Enterprise_Nbr = @Enterprise-- ) = 0 -- Begin Insert into Enterprise_History (Enterprise_Nbr) Values (@Enterprise)-- End Fetch Next From EntCur Into @Enterprise EndClose EntCurDeallocate EntCurDeclare Tab Cursor forSelect H.stat_unit_code as Enterprise_Nbr , RTR.Vat_Nbr , RTR.Tax_Nbr , RTrim(H.after_value_text) as [Action], Left(H.maint_date, 11) + ' - ' + Rtrim(E.Comment_Text) as Event from bf..History_Detail as HInner join bf..History_Event as EOn H.History_Event_NBr = E.History_Event_NBrInner join bf..Enterprise_External_link as ElOn H.Stat_Unit_Code = El.Enterprise_NbrInner join bf..Income_Tax as ITOn El.External_Nbr = IT.Income_Tax_NbrInner Join bf..Representative_Tax_Rel as RTROn IT.Income_Tax_Nbr = RTR.Tax_NbrInner join Enterprise_history as EHOn H.stat_unit_code = EH.Enterprise_nBRWhere EH.ID_Nbr > '25348'Open TabFetch next From Tab Into @Enterprise, @Vat , @Tax , @Var , @ActivityWhile @@fetch_status=0 Begin-- if (-- Select Count(Enterprise_Nbr)-- from Enterprise_History-- Where Enterprise_Nbr = @Enterprise-- ) > 0-- Begin if @Var not in ('Acti', 'Birt', 'Deac', 'Ceas') Begin Update Enterprise_History Set Vat_Nbr = '' + @Vat + '', Tax_Nbr = '' + @Tax + '', Unknown = '' + @Activity + '' where Enterprise_Nbr = '' + @Enterprise + '' End Else Begin Set @sql = 'Update Enterprise_History Set Vat_Nbr = ''' + @Vat + ''', Tax_Nbr = ''' + @Tax + ''', ' + @Var + ' = ''' + @Activity + ''' where Enterprise_Nbr = ''' + @Enterprise + '''' Exec sp_executesql @sql End-- End Fetch next From Tab Into @Enterprise, @Vat , @Tax , @Var , @Activity EndClose TabDeallocate TabYou can't teach an old mouse new clicks.