Regarding stored procedure in sql server 2005

  • i have using two query in stored procedure, i want to use insert query in some time only

    alter proc proc_emp1

    @i int,

    @pempid int,@pempname varchar(30),@pm1 int,@sm1 int

    as

    print @i

    if @i<=1

    begin

    --if @i='I'

    insert into emp1(empid,empname,m1)values(@pempid,@pempname,@pm1)

    end

    if @i>=1

    begin

    update emp1

    set m1=@sm1

    where empname='laila'

    end

    execute procedure:

    exec proc_emp1 @i=0,@pm1=44,@pempid=3,@pempname='khan'

    error:

    Msg 201, Level 16, State 4, Procedure proc_emp1, Line 0

    Procedure or Function 'proc_emp1' expects parameter '@sm1', which was not supplied.

  • boobalanmca07 (12/4/2012)


    i have using two query in stored procedure, i want to use insert query in some time only

    alter proc proc_emp1

    @i int,

    @pempid int,@pempname varchar(30),@pm1 int,@sm1 int

    as

    print @i

    if @i<=1

    begin

    --if @i='I'

    insert into emp1(empid,empname,m1)values(@pempid,@pempname,@pm1)

    end

    if @i>=1

    begin

    update emp1

    set m1=@sm1

    where empname='laila'

    end

    execute procedure:

    exec proc_emp1 @i=0,@pm1=44,@pempid=3,@pempname='khan'

    error:

    Msg 201, Level 16, State 4, Procedure proc_emp1, Line 0

    Procedure or Function 'proc_emp1' expects parameter '@sm1', which was not supplied.

    Not really sure what the question is here but the error message tells you EXACTLY what the problem is. You are calling proc_emp1 and not providing @sm1. Either give that parameter a default value in the proc or add it to the call.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply