Click here to Skip to main content
15,916,378 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
I write a stored procedure:-such as

SQL
alter proc SP_Useraddress(@us_id int)
as
begin
DECLARE @Res varchar(5000)
SET @Res=(SELECT  US_Hno + ', ' + US_Street+ CHAR(13) + CHAR(10) + US_Area+ CHAR(13) + CHAR(10)+
 US_City+ CHAR(13) + CHAR(10)+US_Country+ CHAR(13) + CHAR(10)+US_Mobile AS Address  FROM TBL_User where US_ID=@us_id)
return @Res
end



It execute successfullyl.But when i execute this procedure then give error such as:

Msg 245, Level 16, State 1, Procedure SP_Useraddress, Line 11
Conversion failed when converting the varchar value '#21, M.Palya
Malleshwaram
Bangalore
India
8050552756' to data type int.
I am not able to solve this. I am trying to get out put like this

VB
#21, M.Palya
Malleshwaram
Bangalore
India
8050552756


When I am using print then it is not giving error.But it is not get store in dataset in forented.
Posted

I guess that you are assigning the output of stored procedure to an integer variable. If that's true please change the variable to a string. Please post your result.

Regards
Sebastian
 
Share this answer
 
hi,

u should not return value int as u have declared @res as varchar
 
Share this answer
 
Try converting all your integer values to VARCHAR. Try this:
SQL
ALTER PROC SP_Useraddress(@us_id int)
as
begin
DECLARE @Res varchar(5000)
SET @Res=(SELECT  CONVERT(VARCHAR(20),US_Hno) + ', ' + CONVERT(VARCHAR(20),US_Street)+ CHAR(13) + CHAR(10) +
    CONVERT(VARCHAR(20),US_Area)+ CHAR(13) + CHAR(10)+
 US_City+ CHAR(13) + CHAR(10)+US_Country+ CHAR(13) + CHAR(10)+CONVERT(VARCHAR(20),US_Mobile) AS Address  FROM TBL_User where US_ID=@us_id)
return @Res
end



--Amit
 
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