Connecting Tech Pros Worldwide Forums | Help | Site Map

Displaying records in new line

Newbie
 
Join Date: Jun 2008
Posts: 30
#1: Jul 9 '08
dear all
iam new to sql server. I have a query. I want to display records in a new line.
Iam using char(13) but it won't work.

The table record contains only one field Name


select * from record


DECLARE @x varchar(8000)
SELECT @x =COALESCE(@x+' ',+char(13))+ISNULL(Name,'')+char(13) FROM record
SELECT @x

after executing above query result should come like
abc
xyz
adz

but it comes like abc xyz adz

any help
yogesh

ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Jul 9 '08

re: Displaying records in new line


Where are you running this and why do you need to place it on the second line?

-- CK
Newbie
 
Join Date: Jun 2008
Posts: 30
#3: Jul 10 '08

re: Displaying records in new line


Quote:

Originally Posted by ck9663

Where are you running this and why do you need to place it on the second line?

-- CK

i need in my project.
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#4: Jul 10 '08

re: Displaying records in new line


You might want to consider just doing it on front-end side.

-- CK
Newbie
 
Join Date: Jun 2008
Posts: 30
#5: Jul 10 '08

re: Displaying records in new line


Quote:

Originally Posted by ck9663

You might want to consider just doing it on front-end side.

-- CK

Yes onfrontend side.Any help

Regards
Yogesh
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#6: Jul 10 '08

re: Displaying records in new line


That would depend on your front-end tool.

-- CK
Newbie
 
Join Date: Jun 2008
Posts: 30
#7: Jul 11 '08

re: Displaying records in new line


Quote:

Originally Posted by ck9663

That would depend on your front-end tool.

-- CK

Front end tool is asp.net2005
Delerna's Avatar
Expert
 
Join Date: Jan 2008
Location: Sydney
Posts: 790
#8: Jul 11 '08

re: Displaying records in new line


char(13) is a carriage return
char(10) is a line feed

you need to use both to goto a new line ( char(10) ) and position the cursor at the beginning of the new line( char(13) )

that is why when you open text documents in notepad you sometimes get one line of text with 2 consecutive squares interspersed among the text
1 square is char(10) and the 2nd is char(13)


so
Expand|Select|Wrap|Line Numbers
  1. SELECT @x =COALESCE(@x+' ',+char(13)+char(10))+ISNULL(Name,'')+char(13)+char(10) FROM record
  2.  
  3.  
should work for you
Newbie
 
Join Date: Jun 2008
Posts: 30
#9: Jul 14 '08

re: Displaying records in new line


Thankx a lot
But Iam running above query in sql server. It doesnot display records in next line

Regards
Yogesh
deepuv04's Avatar
Expert
 
Join Date: Nov 2007
Posts: 202
#10: Jul 14 '08

re: Displaying records in new line


Quote:

Originally Posted by hsegoy1979

Thankx a lot
But Iam running above query in sql server. It doesnot display records in next line

Regards
Yogesh

If you are getting results in Gridview mode it appears like in the same line, if you set your setting to view results to text you will get the desired output. it is in sql server.

check how it is appearing if you bind the results to frond-end controls.

Thanks
Newbie
 
Join Date: Jun 2008
Posts: 30
#11: Jul 14 '08

re: Displaying records in new line


Thankx a lot
It is working.
:-)

Regards
Yogesh
Reply