Click here to Skip to main content
12,450,937 members (49,059 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: SQL-Server
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 25-Jan-13 0:25am
Updated 25-Jan-13 4:20am
v5
Comments
OriginalGriff 25-Jan-13 6:31am
   
Any particular error, or just errors in general?
Milind_T 25-Jan-13 6:32am
   
Would you please let us know what kind of error ? And how you are calling the SP?
Milind_T 25-Jan-13 7:03am
   
Has the answer below solved the problem? If yes, accept/upvote. If no, do let us know.
Milind_T 25-Jan-13 7:54am
   
I think you read it wrong. there should NOT be semicolon
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You have inserted end too early
As
 
Begin
insert into emp_registration values(@email,@Name,@FatherName,@Login,@Password,@Department,@Designation)
END
 
if @Designation ='Manager'
  Permalink  
Comments
Milind_T 25-Jan-13 6:33am
   
Nice catch
Vyacheslav Voronenko 25-Jan-13 6:36am
   
:) Thanks
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Comments
Vyacheslav Voronenko 25-Jan-13 6:43am
   
Nice catch :)
Milind_T 25-Jan-13 6:47am
   
Thanks
SChristmas 25-Jan-13 6:43am
   
Correct answer
Milind_T 25-Jan-13 6:47am
   
Thanks.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Along with what was described in Solutions 1 & 2, you also have some other syntax errors:
This is what it should look like
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
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 27 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100