Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Query:
SQL
ALTER procedure get_validupto(@admin_id int)
as begin
DECLARE @NAME NVARCHAR(255)
if(select count(mac_id) from license_master where user_id=@admin_id)>0
begin
set @name=(select validupto from license_master where user_id=@admin_id)
return @name
end
else
set @name='false'
return @name
end

==================================================================
output:
Running [dbo].[get_validupto] ( @admin_id = 2 ).

Conversion failed when converting the nvarchar value '03/04/2013' to data type int.
The thread '01hw191161\c672c752-75c2-44 [53]' (0xfd4) has exited with code 0 (0x0).
No rows affected.
(0 row(s) returned)
@RETURN_VALUE =
Finished running [dbo].[get_validupto].
=================================================================


returned value is '04/03/2013'in varchar format... thn y i m getting this error as
"Conversion failed when converting the nvarchar value '03/04/2013' to data type int."
Posted
Updated 4-Apr-12 2:01am
v2

1 solution

The return for a stored procedure is an integer. If you want other values returned to the caller use an output parameter or a select.

http://www.sqlteam.com/article/stored-procedures-returning-data[^]
 
Share this answer
 
v2
Comments
Sanjeev236 5-Apr-12 2:40am    
data type of the field id nvarchar,i stored value as nvarchar,thn hw can it return value in integer format.as well the variable i am using to return the value is in nvarchar.
[no name] 5-Apr-12 7:10am    
If you want to retrieve the value of this field then use a SELECT or OUTPUT parameter, as I have said. You can't use RETURN.

http://www.sqlteam.com/article/stored-procedures-returning-data

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