下午好,SQL Server 2008 R2中插入存儲過程語法使用的標識字段
我已經寫了將用於插入QuestionText和QuestionStatus到問題表QuestionID int主鍵設置爲一個非常基本的存儲過程擁有身份。
的語法如下:
CREATE PROCEDURE InsertNewQuestion
-- Add the parameters for the stored procedure here
@QuestionText varchar(200), @QuestionStatus bit
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT into Questions
(QuestionText,QuestionStatus)
Values
(@QuestionText),(@QuestionStatus)
END
GO
當我執行存儲過程,收到以下錯誤:
有在INSERT語句中更多的列比 子句中的值指定的值。 VALUES子句中的值數量必須與INSERT語句中指定的列數 相匹配。
用什麼正確的語法來正確插入記錄並允許QuestionID在每次插入時自動遞增?
非常感謝您的幫助和指導。
更新的存儲過程的語法
Your Values line仍然關閉每個參數周圍的缺口。它們都被認爲是由逗號隔開的一個缺口。值(@QuestionText,@QuestionStatus) – klabranche 2011-04-18 20:19:23