CREATE PROCEDURE dbo.storMember
(
@Check nchar (1),
@UserName nvarchar (15),
@Passowerd nvarchar (15)=null,
@Name nvarchar (15)=null,
@Phone nvarchar (15)=null,
@email nvarchar (30)=null,
@CompanyName nvarchar (15)=null ,
@Gender nvarchar (15)=null,
@BarthDay date (15)=null,
@Question nvarchar (15)=null,
@answer nvarchar (100)=null,
)
AS
IF @check = 'a'
BEGIN
INSERT INTO Member
VALUES(@Check, @UserName, @Passowerd, @Name, @Phone, @email,
@CompanyName, @Gender, @BarthDay, @Question, @answer)
END
IF @Check = 'u'
BEGIN
UPDATE Member
SET
Passowerd = @Passowerd, [Name] = @Name, Phone = @Phone,
email = @email, CompanyName = @CompanyName,
Gender = @Gender, BarthDay = @BarthDay,
Question = @Question, Answer = @Answer
WHERE
(UserName = @UserName)
END
IF @check= 'd'
BEGIN
DELETE FROM member
WHERE (userName = @userName)
END
RETURN
答案 0 :(得分:1)
这里有一个多余的逗号:
@answer nvarchar (100)=null,
)
check
也不是一个好的列名,因为它是一个保留的关键字,而date
类型并不是一个大小参数。
这应该有效:
CREATE PROCEDURE dbo.storMember
(
@Check nchar (1),
@UserName nvarchar (15),
@Passowerd nvarchar (15)=null,
@Name nvarchar (15)=null,
@Phone nvarchar (15)=null,
@email nvarchar (30)=null,
@CompanyName nvarchar (15)=null ,
@Gender nvarchar (15)=null,
@BarthDay date =null,
@Question nvarchar (15)=null,
@answer nvarchar (100)=null )
AS
if @check = 'a'
begin
insert into Member values
(@Check,@UserName,@Passowerd,@Name,@Phone,@email,@CompanyName,@Gender,@BarthDay,@Question,@answer)
end
if @Check = 'u'
begin
UPDATE Member
SET Passowerd = @Passowerd,
[Name] = @Name,
Phone = @Phone,
email =@email,
CompanyName = @CompanyName,
Gender = @Gender,
BarthDay = @BarthDay,
Question = @Question,
Answer = @Answer
WHERE (UserName=@UserName)
end
if @check= 'd'
begin
Delete from member
where (userName = @userName)
end
return
您可能希望查看MERGE语句。
答案 1 :(得分:0)
尝试丢失最后一个逗号
CREATE PROCEDURE dbo.storMember
(
@Check nchar (1),
@UserName nvarchar (15),
@Passowerd nvarchar (15)=null,
@Name nvarchar (15)=null,
@Phone nvarchar (15)=null,
@email nvarchar (30)=null,
@CompanyName nvarchar (15)=null ,
@Gender nvarchar (15)=null,
@BarthDay date (15)=null,
@Question nvarchar (15)=null,
@answer nvarchar (100)=null**,**
)