[Solved] why the stored procedure not work and showbox “incorrect syntax near ‘)’. ” [closed]


You have a surplus comma here:

@answer nvarchar      (100)=null,
)

also checkisn’t a good column name as it is a reserved keyword, and the datetype 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]