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 |
|
darenkov
Yak Posting Veteran
90 Posts |
Posted - 2007-06-16 : 12:02:08
|
| i am trying to copy some columns from 'Table A' to 'Table B '(which is easy enough), but I am also trying to insert an additional value into 'Table B' which comes from a parameter (not a value from 'Table A'). I am not sure how to make it work. my code is below:CREATE PROCEDURE [dbo].[prc_CreateOrder]@CustomerID int,@CartID varchar(50)ASBEGINDECLARE @OrderID intSET NOCOUNT ON; INSERT INTO [dbo].[Orders] (CustomerID) VALUES (@CustomerID) SET @OrderID = SCOPE_IDENTITY() INSERT INTO [dbo].[OrderDetails] (OrderID, ProductID, SalePrice, Quantity) (@OrderID, <--I want to insert this SELECT ProductID, Price, Quantity FROM [dbo].[ShoppingCart]) WHERE CartID = @CartID END |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-06-16 : 12:05:19
|
INSERT INTO [dbo].[OrderDetails] (OrderID,ProductID,SalePrice,Quantity)SELECT @OrderID,ProductID,Price,QuantityFROM [dbo].[ShoppingCart]WHERE CartID = @CartID elsasoft.org |
 |
|
|
darenkov
Yak Posting Veteran
90 Posts |
Posted - 2007-06-16 : 12:23:17
|
| thanks muchly |
 |
|
|
|
|
|
|
|