George writes "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 ON INSERT INTO saved_orders_special ( company_name ) VALUES ( @company_name )SELECT @Error = @@ERRORSET @newID = @@IDENTITYIf @Error = 0 BEGIN INSERT INTO saved_cart_special SELECT prod_id, prod_name FROM cart WHERE session_id = @session_id END
Thanks ahead of time,George"