• previously I fetching statecode rows from zipcode tables which contains about 45k rows due to that also cursor was taking too much time so i replaced with state table and fetch statecode from statetable which has about 100 rows and there is great improvement in performance..

    DECLARE @fcIty varchar(40)

    DECLARE @fstate varchar(20)

    declare db_cursor cursor for select StateCode from StateMaster

    open db_cursor

    fetch next from db_cursor into @fstate

    while @@FETCH_STATUS=0

    begin

    UPDATE C

    SET C.STATEID =S.STATEID

    FROM StateMaster S

    INNER JOIN

    WCDentalSQL_TOR..ZipCode Z ON Z.fState COLLATE Latin1_General_CI_AI = S.StateCode COLLATE Latin1_General_CI_AI

    INNER JOIN

    CityMaster C ON C.CityName COLLATE Latin1_General_CI_AI = Z.fCity COLLATE Latin1_General_CI_AI

    WHERE Z.fState=@fstate

    fetch next from db_cursor into @fstate

    end

    close db_cursor

    deallocate db_cursor

    but yes always try to minimize the use of cursor so will use Chris query... :-):-P

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/