If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > How to transfer data from one table to another?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-11-03, 02:59
alshadar alshadar is offline
Registered User
 
Join Date: Nov 2003
Location: Norway
Posts: 6
How to transfer data from one table to another?

I have a temporary shoppingcart-table that I want to transfer to an OrderDetail-table. See following code:

CREATE PROCEDURE add_orderdetails
@CartID int,
@OrderID int

AS
BEGIN TRAN AddOrderDetail
INSERT INTO OrderDetails
(OrderID, ProductID, Quantity, Price)
VALUES
(@OrderID, SELECT ProductID, Quantity, Price FROM Cart WHERE CartID=@CartID)
COMMIT TRAN AddOrderDetail
GO

The OrderID and CartID are inputs from an asp-page.

I got an syntax-error near SELECT and ')'.

I hope someone is able to help me with this. I will be very grateful!

Last edited by alshadar; 11-11-03 at 03:02.
Reply With Quote
  #2 (permalink)  
Old 11-11-03, 07:13
alshadar alshadar is offline
Registered User
 
Join Date: Nov 2003
Location: Norway
Posts: 6
I helped myself. If I remove the VALUES, and put the SELECT-sentence like this:
SELECT @OrderID AS OrderID, ProductID, .....

Jippi )
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On