Click here to Skip to main content
15,898,692 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to like this:

SQL
SELECT US_Hno + ', ' + US_Street
+ CHAR(13) + CHAR(10) --new line feed char
+ 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=34


But it is showing result like this-
#21, M.Palya Malleshwaram Bangalore India 8050552756

But I wnat to display in this format:

#21, M.Palya
Malleshwaram
Bangalore
India

Please help me....
8050552756
Posted
Comments
AmitGajjar 2-Aug-12 10:07am    
it's not always you do work in stored procedure this could be simple done from UI side.

Hi Raju,
Use this:
SQL
DECLARE @Res VARCHAR(50)
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=34)
PRINT @Res


Select statement will select the data in table, hence, it won't display in new line.

Try this:
SQL
SELECT US_Hno + ', ' + US_Street
+ CHAR(13) + '</br>' -- This will break the line in front-end
+ 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=34


--Amit
 
Share this answer
 
v3
Comments
Raju2049 2-Aug-12 7:32am    
Hi, amit I am trying to do this by stored procedure. after that take value in dataset. And I think it is not possible to get data by using print statement.
Why the way i am using select and return option again it comes in new line
_Amy 2-Aug-12 7:39am    
Then instead of CHAR(10) use '</br>'. Try my updated answer.
__TR__ 2-Aug-12 7:51am    
My 5.
_Amy 2-Aug-12 7:56am    
Thanks Tejas. :)
__TR__ 2-Aug-12 12:46pm    
You are welcome.
hi,

use this dont use html tag inside the procedure


SELECT US_Hno + ', ' + US_Street
+ CHAR(13) + '/n'
+ US_Area
+ CHAR(13) + '/n'
+ US_City
+ CHAR(13) + '/n'
+US_Country
+ CHAR(13) + '/n'
+US_Mobile
AS Address FROM TBL_User where US_ID=34
 
Share this answer
 
v2
Just set your result to text format instead of table format in sql server management studio and the new line will work.
 
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