-
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'
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?
-
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'
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
-
Forum Rules
|
|