You have a surplus comma here:
@answer nvarchar (100)=null,
)
also check
isn’t a good column name as it is a reserved keyword, and the date
type doesn’t take a size parameter.
This should work:
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
You might want to look at the MERGE statement though.
solved why the stored procedure not work and showbox “incorrect syntax near ‘)’. ” [closed]