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)
  • 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. – mustaccio May 17 '15 at 16:48
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.