Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Regarding stored procedure in sql server 2005 Expand / Collapse
Author
Message
Posted Tuesday, December 04, 2012 7:30 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, December 04, 2012 8:00 AM
Points: 13, Visits: 14
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.
Post #1392480
Posted Tuesday, December 04, 2012 7:35 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: 2 days ago @ 1:17 PM
Points: 8,641, Visits: 8,273
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Post #1392485
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse