2013-08-17 213 views
1

我想創建一個存儲過程,但它在執行時給我一個錯誤。在SQL Server 2008中存儲過程

Msg 156,Level 15,State 1,Procedure SignupUser,Line 13 關鍵字'User'附近的語法不正確。

我的存儲過程是:

CREATE PROCEDURE SignupUser 
(
    @FirstName nvarchar(25), 
    @LastName nvarchar(25), 
    @Email nvarchar(50), 
    @Password nvarchar(25), 
    @Mobile nvarchar(20), 
    @City nvarchar(25), 
    @StateProvince nvarchar(25), 
    @Country nvarchar(25), 
    @Type nvarchar(1), 
    @DateOfJoining Datetime 
) 
AS 
    INSERT INTO User 
    (
     FirstName,LastName,Email,Password, 
     Mobile,City,StateProvince,Country,Type,DateOfJoining 
    ) 
    VALUES 
    (
     @FirstName,@LastName,@Email,@Password, 
     @Mobile,@City,@StateProvince,@Country,@Type,@DateOfJoining 
    ) 

回答

2

用戶在SQL Server中的reserved keyword。用方括號它:

CREATE PROCEDURE SignupUser 
(
    @FirstName nvarchar(25), 
    @LastName nvarchar(25), 
    @Email nvarchar(50), 
    @Password nvarchar(25), 
    @Mobile nvarchar(20), 
    @City nvarchar(25), 
    @StateProvince nvarchar(25), 
    @Country nvarchar(25), 
    @Type nvarchar(1), 
    @DateOfJoining Datetime 
) 
AS 
    INSERT INTO [User] 
    (
     FirstName,LastName,Email,Password, 
     Mobile,City,StateProvince,Country,Type,DateOfJoining 
    ) 
    VALUES 
    (
     @FirstName,@LastName,@Email,@Password, 
     @Mobile,@City,@StateProvince,@Country,@Type,@DateOfJoining 
    ) 
end 
0

用戶在SQL關鍵字,你需要把周圍的表或列名稱括號是在SQL關鍵字。像這樣:

[USER] or [GRANT] 
相關問題