how to add \n in sqlquery

Posted by Klbaiju under Sql Server on 1/21/2011 | Points: 10 | Views : 3680 | Status : [Member] | Replies : 4
Hi,
this is my query
select customerid,+'contact:'+companyname +' ' +'Address :'+ contactname+' '+'City :'+city as details from customers
the output is

Customerid details

Alfki contact :dddd Address :jjjj City: hhhh

ineed the out put like this

Customerid details

Alfki contact :dddd
Address :jjjj
City :hhhh

how it is possible. means i want to add \n between fields i tried several times but showing error.


Regards
K L BAIJU




Responses

Posted by: T.saravanan on: 1/21/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi K L BAIJU,

Where do you show your output in Sql Server (or) other?

Thanks,
T.Saravanan

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Klbaiju on: 1/21/2011 [Member] Starter | Points: 25

Up
0
Down
I want to display in as tooltip in gridview

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: PandianS on: 1/21/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi

You can use the below query :
SELECT customerid, ' contact:' + companyname + CHAR(10) + 'Address :'+ contactname+ CHAR(10) +'City :' + city as details from customers
Cheers
www.sqlserverbuddy.blogspot.com


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 1/21/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

@PandianS Its simply super.

@Klbaiju use Mr.PandianS query and also include and special character in between the columns after get the output using that special character to split the output and added in tooltip.

For ex:
 SELECT customerid, ' contact:' + companyname + CHAR(10 )' +' #' + 'Address :'+ contactname+ CHAR(10) +'#' +'City :' + city as details from customers


Thanks,
T.Saravanan

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response