SQL Server Performance

adding rows without duplicates

Discussion in 'General Developer Questions' started by tony king, Jul 8, 2004.

  1. tony king New Member

    I am writing a stored proc that check entries in one table and updates another. The latter table does no accept duplicates. It does not seem to update any records. i am a novice in sql so please help.
    Regards tony
    ********************************

    CREATE PROCEDURE TONY_ABC AS

    DECLARE @NDS NVARCHAR(50)
    DECLARE @ASA NVARCHAR(50)
    DECLARE @DATESCANNED DATETIME
    DECLARE @REFERENCE NVARCHAR(50)

    PRINT @NDS

    DECLARE csrSkyout1 CURSOR --FORWARD_ONLY READ_ONLY STATIC
    FOR

    SELECT TOP 1 NDS=@NDS,
    ASA=@ASA,
    [DATE SCANNED]=@DATESCANNED,
    REFERENCE=@REFERENCE
    FROM TMPSCANSOUT


    OPEN csrSkyout1


    FETCH NEXT FROM csrSkyout1
    INTO
    @NDS, @ASA, @DATESCANNED, @REFERENCE



    -- 2.4 Main Fetch Loop


    WHILE @@FETCH_STATUS = 0

    BEGIN

    UPDATE SKYSCANSOUT
    SET
    NDS = @NDS,
    ASA = @ASA,
    [DATE SCANNED] = @DATESCANNED,
    REFERENCE = @REFERENCE


    FETCH NEXT FROM csrSkyout1 INTO @NDS, @ASA, @DATESCANNED, @REFERENCE
    END
    GO
    *********************************************
  2. derrickleggett New Member

    Cross Post

    MeanOldDBA
    derrickleggett@hotmail.com

    When life gives you a lemon, fire the DBA.

Share This Page