Update or Insert

  • I run the following query:

    update [product-summary] set

    [product-summary].price = convert(money,[product-extract].price),

    [product-summary].[productdescription] = [product-extract].[desc],

    [product-summary].invcount = [product-extract].invcount

    from [product-summary] inner join [product-extract] on [product-extract].shortsku = [product-summary].shortsku

    go

    my problem is that if the shortsku exists in table [product-extract] and not in [product-summary] i want to insert the record into [product-summary]. how can i achieve this?


    </cm>

  • Try

    INSERT INTO [product-summary] (columsntobeinserted) SELECT correspondingcolumns FROM [product-extract] WHERE shortsku NOT IN (SELECT shortsku FROM [product-summary])

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply