Home Forums SQL Server 7,2000 T-SQL Insert daily records from one table to individual merchant tables RE: Insert daily records from one table to individual merchant tables

  • Hi,

    If it helps - yes you can do away with cursors and still step through everything:-

      SET @pk = (SELECT MIN(PK) FROM #Values)

      SET @MaxPK = (SELECT MAX(PK) FROM #Values)

      WHILE @pk <= @MaxPK

      BEGIN

    --Do whatever you are doing

    SET @pk = (SELECT MIN(PK) FROM #Values WHERE PK > @pk)

      END

    Though i'm not too certain what good it will do you in this scenario......

    Have you checked the execution plan to see where the biggest costs are?

    Steve

    We need men who can dream of things that never were.