i have two column in table

select Col1 + ' ' + Col2 from test

It gives output as
Arun Kumar

But i want output as
Arun
Kumar

Can anyone help me out

Recommended Answers

All 10 Replies

Thanks for giving your valuable time

This Guy is using Print
But i want the output using select Query

I don't think it matters. It matters what your output is.

Can you give us a bit more info on what you are doing with the results? (Have you connected via .Net/PHP/Query Analyzer (Or what do they call it nowadays) and are you binding them to a control/displaying them in a grid/reading them line by line like a text file...).

PS: I know I didn't ask earlier, but you don't mean getting a new record, but a new line in the same record + field as Arun (col1), right?

Yes i required the new line in the same record
Thanks Adam

I agree with the solution provided by adam_k

SELECT Col1 + CHAR(13) + CHAR(10) + Col2 FROM test

It may not shown in query result. but in text area or in your multi line text box new line will be visible.

Hi urtrivedi
Thanks for giving your time

Previously When i googled i got the same solution
But in output its given space.
I am running the Query in <b>SQL Query Analyzer</b>

Is your output switched to text or grid ?

In text mode it is showing in next line
And in grid its showing in the same line giving space between the two string

That would be correct, like I've mentioned in my first post it's what you should be getting.
I'm pretty sure that you cannot feed a new line in grid mode, as it will fit the value in a cell.

I got the solution
Actually i develop reports in ssrs
And when i Developed the Report i got my desired output

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.