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 Answer 1
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.
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.