0

I am trying to write a stored procedure that has parameters and updates a table with the supplied title and middleName for the person having the businessEnityID.

Create Procedure sp_PersonEditor
 @BusinessEntityId (int, not null),
 @PersonType (nchar(2), not null),
 @NameStyle (bit, not null),
 @Title (nvarchar(8), null),
 @FirstName (nvarchar (50), not null),
 @MiddleName (nvarchar (50), null),
 @LastName (nvarchar (50), not null), 
 @Suffix (nvarchar (10), null),
 @ModifiedDate (datetime, not null)
as
 update BussinessEntityId
 set Title = @NewTitle, MiddleName = @NewMiddleName
 where BussinessEntityId = @BussinessEntityId
end

This is the error message I am getting:

Incorrect syntax near ','.

These are my columns for the database.

BusinessEntityId (int, not null)
PersonType (nchar(2), not null)
NameStyle (bit, not null)
Title (nvarchar(8), null)
FirstName (nvarchar(50), not null)
MiddleName (nvarchar(50), null)
LastName (nvarchar(50),not null) 
Suffix (nvarchar(10,)null)
ModifiedDate (datetime, not null)
mustaccio
28.6k24 gold badges60 silver badges77 bronze badges
asked May 17, 2015 at 16:34
1
  • 1
    Do you think that mentioning the database and version you are working with might be useful? The CREATE PROCEDURE statement seems to have incorrect syntax. For example, the procedure parameter list is usually enclosed in parentheses, and the statements within it are typically terminated with semicolons. Commented May 17, 2015 at 16:48

1 Answer 1

0

If this is SQL Server procedure, leave out the parenthesis and commas:

Create Procedure sp_PersonEditor
 @BusinessEntityId int not null,
 @PersonType nchar(2) not null,
 @NameStyle bit not null,
 @Title nvarchar(8) null,
 @FirstName nvarchar (50) not null,
 @MiddleName nvarchar (50) null,
 @LastName nvarchar (50) not null, 
 @Suffix nvarchar (10) null,
 @ModifiedDate datetime not null
as
 update BusinessEntityId
 set Title = @Title, MiddleName = @MiddleName
 where BusinessEntityId = @BusinessEntityId
end

Also, I would not recommend naming procedures sp* since that's meant for system procedures and causes performance overhead. Fixed also the typos (Business vs Bussiness). You don't have variables New* so I removed that prefix too.

answered May 17, 2015 at 20:29

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.