Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello There, I am New To Sql Server 2005, Can AnyOne Tell Me the Example of Stored Procedure That Returns The DateTime Value.
SQL
Create Proc MyProc
AS
DECLARE @dt DateTime 
            SELECT @dt =GetDate()
Return @dt


----------------------------------
I Want to Store The @dt In a Different Variable
SQL
DECLARE @Result Datetime
SET @Result=@dt

Is It Possible to Store The Result Of Stored Procedure in A Variable

Regards.
Posted
Updated 24-Aug-11 21:17pm
v3
Comments
Mahendra.p25 25-Aug-11 2:51am    
yes you can declare another variable
and select @Result

try this

SQL
Create Proc MyProc
AS
DECLARE @dt DateTime
set @dt =GetDate()
select @dt as CurrentDatetime
 
Share this answer
 
You can use OUTPUT parameter to return values from a stored procedure. Check the below link.

http://sqlserverpedia.com/wiki/Stored_Procedures_-_Output_Parameters_%26_Return_Values[^]
 
Share this answer
 

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