SQL Server Performance

Update query

Discussion in 'SQL Server 2005 General Developer Questions' started by ralph1972, Nov 5, 2007.

  1. ralph1972 New Member

    Hello,
    I want to write an update query for using articles in an inventory module.
    Invent_header
    ID STOREID
    Invent_art table
    ARTID INVHEADID QTY_APP QTY_COUNT
    Stock Table
    ARTID STOREID STOCK
    Now I want to write an update query which updates the files QTY_APP in the invent_art table with the Stock field from the Stock table.
    Is it possible to write this in 1 query? Is so can someone help me out please.
    Thanks

    Ralph
  2. anandchatterjee New Member

    you can update a single table in a update query but to perform it in atomic level you can use begin and commit tran.
  3. ndinakar Member

    Try something like this:
    UPDATE IA
    SET QTY_APP = ST.STOCK
    FROM Invent_Art IA
    JOIN Stock ST ON IA.ARTID = ST.ARTID
    WHERE <condition>
  4. deepu_v04 New Member

    or u can Try something like this:
    UPDATE Invent_Art
    SET QTY_APP = ( select STOCK FROM Stock where Invent_Art.dbo.ARTID = Stock .dbo.ARTID)
    WHERE <condition>

Share This Page