Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Posts
    2

    Lightbulb Unanswered: Update a field with a Stored Procedure

    I need to update a field with the code below, is it possible to do this with a table join? The Query Analyzer is giving me an error at "Join".

    An example:
    (ManufSerNo is a field in table ASSETS,
    Status is a field in table HISTORY)

    GO

    CREATE PROCEDURE sp_ChngeAssetStatus

    @ManufSerNo char(10),
    @Status varchar(1)

    AS

    UPDATE HISTORY
    SET Status = @Status
    JOIN ASSETS
    ON HISTORY.AssetID = ASSETS.AssetID
    WHERE ManufSerNo = @ManufSerNo
    --ELSE
    --RAISERROR ('Sorry, but the Asset ID specified does not exist. Record not updated.', 10 , 1)

    GO

  2. #2
    Join Date
    Oct 2003
    Posts
    357
    Hi, try this
    Code:
    UPDATE HISTORY H
    SET Status = 'Satus desc here'
    from ASSETS A where H.AssetID = A.AssetID
    and ManufSerNo = 'ManufSerNo desc'
    Madhivanan

  3. #3
    Join Date
    Dec 2004
    Posts
    2
    Madhivanan,

    I feel silly, must be working on too much.

    THANKS!

Posting Permissions

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