Click here to Skip to main content
15,891,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
EmployeeName nvarchar(50),
Address nvarchar(50),
Phone nvarchar(50),
Department nvarchar(50),
Gender nvarchar(50),
IsAvailable bit)

--add procedure
SQL
create procedure add_Emp @EmployeeNo nvarchar(50),@EmployeeName nvarchar(50),@Address nvarchar(50),@Phone nvarchar(50),@Department nvarchar(50),@Gender nvarchar(50),@IsAvailable bit
AS
Begin
insert into employee1(EmployeeNo,EmployeeName,Address,Phone,Department,Gender,IsAvailable) values (@EmployeeNo,@EmployeeName,@Address,@Phone,@Department,@Gender,@IsAvailable)
end


---error message
Quote:
Msg 111, Level 15, State 1, Procedure add_Emp, Line 12 'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
Posted
Updated 9-Sep-15 2:41am
v2

Hi,
Error message states solution itself. you cannot add declare statements above create procedure statement,Create statement has to be first statement in query batch .Remove those variable declaration and it should work.

Regards,
Amol Birar
 
Share this answer
 
Comments
Herman<T>.Instance 9-Sep-15 9:41am    
He can put that in comments in his stored procedure
Place GO right before your Create procedure statement. The GO statement must be on a line by itself:
SQL
GO
create procedure add_Emp @EmployeeNo nvarchar(50),@EmployeeName nvarchar(50),@Address nvarchar(50),@Phone nvarchar(50),@Department nvarchar(50),@Gender nvarchar(50),@IsAvailable bit
AS
Begin
insert into employee1(EmployeeNo,EmployeeName,Address,Phone,Department,Gender,IsAvailable) values (@EmployeeNo,@EmployeeName,@Address,@Phone,@Department,@Gender,@IsAvailable)
end
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900