Results 1 to 2 of 2

Thread: INSERT in stored proc

  1. #1
    Patrick Guest

    INSERT in stored proc

    given a variable @requestID and @session ID, I need to move requests from
    a holding table to the request table using the generated request ID.

    In a perfect world...

    INSERT INTO Requests(ReqID, field1, field2)
    VALUES (SELECT @requestID AS RID, field1, field2
    FROM holding WHERE session = '1234&#39

    So that all 5 or so rows from the holding table having a session ID of 1234
    get transfered to the request table using the variable value @requestid as
    the value satisfying ReqID.

    Any ideas?

  2. #2
    Jim W Guest

    INSERT in stored proc (reply)

    Just get rid of the values phrase:

    INSERT INTO Requests(ReqID, field1, field2)
    SELECT @requestID AS RID, field1, field2
    FROM holding WHERE session = '1234'

    This is called an Insert/Select query. It is a wonderful thing.

    ------------
    Patrick at 1/10/01 4:48:16 PM

    given a variable @requestID and @session ID, I need to move requests from
    a holding table to the request table using the generated request ID.

    In a perfect world...

    INSERT INTO Requests(ReqID, field1, field2)
    VALUES (SELECT @requestID AS RID, field1, field2
    FROM holding WHERE session = '1234&#39

    So that all 5 or so rows from the holding table having a session ID of 1234
    get transfered to the request table using the variable value @requestid as
    the value satisfying ReqID.

    Any ideas?

Posting Permissions

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