Results 1 to 3 of 3

Thread: Something error

  1. #1
    Join Date
    Sep 2010
    Posts
    6

    Unanswered: Something error

    Alter Procedure AddNewEmployee
    (
    @FirstName varchar(100),
    @LastName varchar(100),
    @City varchar(70),
    @No varchar(20),
    @Street varchar(150),
    @PostalCode varchar(50),
    @Gender varchar(10),
    @DateOfBirth Datetime,
    @Job varchar(200),
    @StartDate datetime,
    @BranchID varchar(50)
    )

    As
    Begin
    Insert into Employee(EmployeeID,FirstName,LastName,City,No,Str eet,PostalCode,Gender,DateOfBirth,Job,Start_Date,B ranchID)
    values(DBO.GeneratePrimaryKey('Employee'),@FirstNa me,@LastName,@City,@No,@Street,@PostalCode,@Gender ,@DateOfBirth,@Job,@StartDate,@BranchID)

    declare @cvalue varchar(10)
    set @cvalue=(select value from Primarykeys where Tablename='Employee')
    set @cvalue=@cvalue+1

    Update Primarykeys set value=@cvalue where tablename='Employee'
    end

    This is my procedure and when i try to execute it i got the following error

    Msg 102, Level 15, State 1, Line 3
    Incorrect syntax near ')'.

    i checked my codings 100 times

    iam executing it like this

    Execute AddNewEmployee 'Akram','Mohamed','Kandy','139','Main street','20850','Male',getdate(),'IT Developer',getdate(),'B1'


    please any body let me know what is the problem

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I'm sorry, but posting your homework for us to debug is rude. Doing that without comment or giving us a clue what you are doing and changing makes it even more rude.

    Look at the part that you changed since it last worked. The error is definitely on line three, and depending on your database collation may include more than one error.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Sep 2010
    Posts
    15
    Is it the homework? Anyway, I'm not sure the role of function GeneratePrimaryKey ... just provide some suggests ...

    As
    Begin
    Insert into Employee(EmployeeID,FirstName,LastName,City,No,Str eet,PostalCode,Gender,DateOfBirth,Job,Start_Date,B ranchID)
    values(DBO.GeneratePrimaryKey('Employee'),@FirstNa me,@LastName,@City,@No,@Street,@PostalCode,@Gender ,@DateOfBirth,@Job,@StartDate,@BranchID)

    declare @cvalue varchar(10)
    set @cvalue=(select value from Primarykeys where Tablename='Employee')
    set @cvalue=@cvalue+1

    Update Primarykeys set value=@cvalue where tablename='Employee'

    end
    The red part has space.

    Also, the blue part can be replaced by: update P set value=value+1 from Primarykeys P where tablename='Employee'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •