Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
CREATE PROCEDURE empinsert
	@email varchar(50),
	@Name varchar(50),
	@FatherName varchar(50),
	@Login varchar(50),
	@Password varchar(50),
	@Department Varchar(50),
	@Designation varchar(50),
	@weightage int
	As
	
	Begin 
	insert into emp_registration values(@email,@Name,@FatherName,@Login,@Password,@Department,@Designation)
	END
	
				if @Designation ='Manager'
                
                    @weightage = 7;
                
              else if @Designation = 'Asst.Manager'
                
                    @weightage = 5;
                
                else if @Designation= 'Deputy Manager'
                                    
                    @weightage = 6;
                
               else if @Designation = 'Team Leader'
               
                   @weightage = 4;
               
 
              else if @Designation = 'Executives'
                
                    @weightage= 3;
                
                else if @Designation = 'Clerk'
                
                    @weightage = 3;
                
 
               else if @Designation= "Officeassistant"
                
                    @weightage = 2;
                
	Begin				
	insert into Users values(@Login,@Password,@weightage)
	End
	Go
Posted
Updated 25-Jan-13 4:20am
v5
Comments
OriginalGriff 25-Jan-13 6:31am    
Any particular error, or just errors in general?
MT_ 25-Jan-13 6:32am    
Would you please let us know what kind of error ? And how you are calling the SP?
MT_ 25-Jan-13 7:03am    
Has the answer below solved the problem? If yes, accept/upvote. If no, do let us know.
MT_ 25-Jan-13 7:54am    
I think you read it wrong. there should NOT be semicolon

You have inserted end too early
SQL
As

Begin
insert into emp_registration values(@email,@Name,@FatherName,@Login,@Password,@Department,@Designation)
END

if @Designation ='Manager'
 
Share this answer
 
Comments
MT_ 25-Jan-13 6:33am    
Nice catch
Vyacheslav Voronenko 25-Jan-13 6:36am    
:) Thanks
Well wel..

Besides what Vyacheslav said above, this is not C# and there should not be a "semi-colon" after @weightage = 4;

Hope that helps
Milind
 
Share this answer
 
Comments
Vyacheslav Voronenko 25-Jan-13 6:43am    
Nice catch :)
MT_ 25-Jan-13 6:47am    
Thanks
Sandesh M Patil 25-Jan-13 6:43am    
Correct answer
MT_ 25-Jan-13 6:47am    
Thanks.
Along with what was described in Solutions 1 & 2, you also have some other syntax errors:
This is what it should look like
SQL
CREATE PROCEDURE empinsert
   @email varchar(50),
   @Name varchar(50),
   @FatherName varchar(50),
   @Login varchar(50),
   @Password varchar(50),
   @Department Varchar(50),
   @Designation varchar(50),
   @weightage int
   As
   Begin 

   insert into emp_registration values(@email,@Name,@FatherName,@Login,@Password,@Department,@Designation)
   END 

   if @Designation ='Manager'
      SET @weightage = 7
   else if @Designation = 'Asst.Manager'
      SET @weightage = 5
   else if @Designation= 'Deputy Manager'
      SET @weightage = 6
   else if @Designation = 'Team Leader'
      SET @weightage = 4
   else if @Designation = 'Executives'
      SET @weightage= 3                
   else if @Designation = 'Clerk'
      SET @weightage = 3                 
   else if @Designation= "Officeassistant"                
      SET @weightage = 2

   BEGIN
   insert into Users values(@Login,@Password,@weightage)
End
Go
 
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