晚上好一切,存儲過程多表插入錯誤:無法將NULL值插入列
我創建了以下存儲過程:
CREATE PROCEDURE AddQuote
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
Declare @CompanyName nvarchar(50),
@Addr nvarchar(50),
@City nvarchar(50),
@State nvarchar(2),
@Zip nvarchar(5),
@NeedDate datetime,
@PartNumber float,
@Qty int
-- Insert statements for procedure here
Insert into dbo.Customers
(CompanyName, Address, City, State, ZipCode)
Values (@CompanyName, @Addr, @City, @State, @Zip)
Insert into dbo.Orders
(NeedbyDate)
Values(@NeedDate)
Insert into dbo.OrderDetail
(fkPartNumber,Qty)
Values (@PartNumber,@Qty)
END
GO
當我執行AddQuote,我收到一個錯誤,說明:
Msg 515, Level 16, State 2, Procedure AddQuote, Line 31
Cannot insert the value NULL into column 'ID', table 'Diel_inventory.dbo.OrderDetail'; column does not allow nulls. INSERT fails.
The statement has been terminated.
我明白,我已經設置數量字段不允許爲空,並希望繼續這樣做。但是,是否還有其他語法更改,以確保此sproc正常工作?
感謝, 希德
這不是抱怨數量。它在抱怨ID。 OrderDetail中的ID列是否有默認值?你沒有給它一個價值。 – 2010-05-06 05:34:10