Click here to Skip to main content
11,567,539 members (44,015 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL
Query:
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 4-Apr-12 1:10am
Edited 4-Apr-12 2:01am
RyanDev161.8K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
v2
Comments
Sanjeev236 at 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.
Mark Nischalke at 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)

  Print Answers RSS


Advertise | Privacy | Mobile
Web03 | 2.8.150624.2 | Last Updated 5 Apr 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100