Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ateup
Starting Member
5 Posts |
Posted - 2001-10-15 : 09:02:17
|
| I am trying to insert a record into a saved_orders table. Grab the just inserted id from the table using @@IDENTITY. I know how to do this. It is this part I am lost on. I want to insert all the records from the cart table into the saved_cart table and include the just inserted saved_orders id value. The code below is what I am trying to due. I know this isnt right but thought I would list it.CREATE PROCEDURE sp_INSERT_ORDER_SPECIAL_TEST@session_id Varchar(50),@company_name Varchar(50)ASDECLARE @Error IntDECLARE @newID IntSET NOCOUNT ONINSERT INTO saved_orders_special (company_name) VALUES (@company_name)SELECT @Error = @@ERRORSET @newID = @@IDENTITYIf @Error = 0BEGININSERT INTO saved_cart_special @newID, SELECT prod_id, prod_name FROM cart WHERE session_id = @session_idENDThanks ahead of time,George |
|
|
|
|
|