user3190075
user3190075

Reputation: 79

new line into SELECT query sql server 2005

I want to do a new line in my sql select

I try this but it won't work

SELECT '1' + char(13) + '2'

AND

SELECT '1' + char(13) + char(10) + '2'

it always return 12

thanks for your answers in fact I try to export data from sql to TXT file but when I execute the bcp file it return concatenate rows

Upvotes: 2

Views: 1061

Answers (2)

Dan
Dan

Reputation: 5231

The new line is in your result. If you copy and paste the result from your query into notepad, for example, you'll see 1, new line, 2. The reason you see 1 2 in your result in the results window is because you are returning 1 row. Notice that len('1' + char(13) + char(10) + '2') = 4, that is because your chars are present, it's just represented as a single row (with multiple lines in the row).

Upvotes: 1

Dave Zych
Dave Zych

Reputation: 21887

That's just the way SSMS displays the results. If you copy the result out into Notepad, or as Lamak says choose Results to Text you should see the newlines in place.

Upvotes: 1

Related Questions