Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2004
    Posts
    3

    Unanswered: Update column in multiple tables

    I have multiple product tables with a "ListPrice" column. I want to use a temporary table that contains "ProductID" and "ListPrice" columns and execute a stored procedure that will update the "ListPrice" column in all product tables with the "ListPrice" from temporary table where "ProductID" from temporary table matches "ProductID" in product tables.

    I am new at writing stored procedures.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I'd use:
    Code:
    UPDATE a
       SET a.ListPrice = b.ListPrice
       FROM product_table AS a
       JOIN temp_table AS b
          ON (b.ProductID = a.ProductID)
    -PatP

  3. #3
    Join Date
    Jun 2004
    Posts
    3
    I'm assuming that I would repeat this for each product table. Can I then encapsulate this all in one stored procedure for ease of use?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •