Click here to Skip to main content
15,915,780 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Iam not good in sp's and functions anybody's help to me
SQL
create procedure status_change
(
@diff int output
)
as
begin
set @diff=(select datediff(day,last_login,getdate()) from samp_data);
if(@diff>=90)
begin
update samp_data set status='deactive'
end
end

when ever iam executing this procedure it's giving error like
Procedure or Function 'status_change' expects parameter '@diff', which was not supplied.

what's wrong in this procedure
why the result value is not stored in localvariale @diff
Posted
Updated 28-Nov-11 0:59am
v2

Execute like this..

SQL
DECLARE @Diff int
EXEC status_change @Diff
PRINT @Diff
 
Share this answer
 
Comments
swarup65 28-Nov-11 8:05am    
Thank u for ur reply. I got solution
Use Select statement , if you dont want to pass arguments.

Like :

SQL
create procedure status_change
(

)
as
begin
Declare @diff int
set @diff=(select datediff(day,last_login,getdate()) from samp_data);
if(@diff>=90)
begin
update samp_data set status='deactive'
end
Select @diff
end
 
Share this answer
 
Comments
swarup65 28-Nov-11 8:05am    
Thank u for ur reply. I got solution for this problem

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