sql server中的存储过程错误 [英] Stored Procedure error in sql server
本文介绍了sql server中的存储过程错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
CREATE PROCEDURE [SP_PersonelInfo]
@[personelcode] varchar (20),
@[firstname] nvarchar(50),
@[lastname) nvarchar(50),
@[FK_pID] int,
@[employmenttype] nvarchar(50),
@[employmentdate] char(10)
begin
insert into PersonelInfo(PersonelCode,FirstName,LastName)
Values([personelcode],[firstname],[lastname])
DECLARE @lstprsnlID INT
set @lstprsnlID = SCOPE_IDENTITY();
insert into EmploymentInfo(FK_pID,EmploymentType,EmploymentDate)
Values([lstprsnlID],[employmenttype],[employmentdate])
END
go
the error is on this part:varchar (20)
and the error text is: "Incorrect syntax near '20'. Expecting SELECT, or '('"
and you can see error picture here:
<a href="http://i44.tinypic.com/v5a79d.png">error</a>
推荐答案
CREATE PROCEDURE [SP_PersonelInfo](
@personelcode varchar(20),
@firstname nvarchar(50),
@lastname nvarchar(50),
@FK_pID int,
@employmenttype nvarchar(50),
@employmentdate char(10))
as
set nocount on
begin
insert into PersonelInfo(PersonelCode,FirstName,LastName)
Values(@personelcode,@firstname,@lastname)
DECLARE @lstprsnlID INT
set @lstprsnlID = SCOPE_IDENTITY();
insert into PersonelInfo(FK_pID,EmploymentType,EmploymentDate)
Values(@lstprsnlID,@employmenttype,@employmentdate)
END
set nocount off
删除所有括号!!!
Remove all your brackets!!!
CREATE PROCEDURE [SP_PersonelInfo]
@personelcode varchar (20),
@firstname nvarchar(50),
@lastname nvarchar(50),
@FK_pID int,
@employmenttype nvarchar(50),
@employmentdate char(10)
hi.remove来自你的参数的支架。
hi.remove bracket from your paramters.
这篇关于sql server中的存储过程错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文