insert 语句与 column foreign key 约束 'fk_orders_users' 冲突。该冲突发生于数
谁能帮忙看下这个问题是什么,怎么解决我ORDERID的存储过程是CREATEPROCEDUREAddOrder@UserIDint,@ShoppingCartIDnvar...
谁能帮忙看下这个问题是什么,怎么解决
我ORDERID的存储过程是
CREATE PROCEDURE AddOrder
@UserID int,
@ShoppingCartID nvarchar(50),
@OrderDate datetime,
@OrderID int OUTPUT
AS
BEGIN TRAN OrderAdd
INSERT INTO Orders
(UserID,
OrderDate
)
Values
(@UserID,
@OrderDate)
SELECT
@OrderID = @@Identity
INSERT INTO OrderContent
(OrderID,
wareID,
wareQuantity,
UnitCost)
SELECT
@OrderID,
Shopping.wareID,
wareQuantity,
ware.SalePrice
FROM
Shopping
INNER JOIN ware ON Shopping.wareID = ware.wareID
WHERE
ShoppingID = @ShoppingCartID
EXEC EmptyShoppingCart @ShoppingCartId
COMMIT TRAN OrderAdd
GO 展开
我ORDERID的存储过程是
CREATE PROCEDURE AddOrder
@UserID int,
@ShoppingCartID nvarchar(50),
@OrderDate datetime,
@OrderID int OUTPUT
AS
BEGIN TRAN OrderAdd
INSERT INTO Orders
(UserID,
OrderDate
)
Values
(@UserID,
@OrderDate)
SELECT
@OrderID = @@Identity
INSERT INTO OrderContent
(OrderID,
wareID,
wareQuantity,
UnitCost)
SELECT
@OrderID,
Shopping.wareID,
wareQuantity,
ware.SalePrice
FROM
Shopping
INNER JOIN ware ON Shopping.wareID = ware.wareID
WHERE
ShoppingID = @ShoppingCartID
EXEC EmptyShoppingCart @ShoppingCartId
COMMIT TRAN OrderAdd
GO 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询