user4760387
user4760387

Reputation:

breakline in sql server result

I have this result and i need to break it in 2 or more lines depending the { }...

this is my table: select distinct col1 from table1

the result for col1 is:

"{ CN_COND_ID:0, CN_TYPE:1, CN_VALUE:2, CN_TARGET:1682, CN_SOURCE:1684, CN_DESCRIPTION: } { CN_COND_ID:1, CN_TYPE:1, CN_VALUE:2, CN_TARGET:1685, CN_SOURCE:1684, CN_DESCRIPTION: } { CN_COND_ID:2, CN_TYPE:1, CN_VALUE:2, CN_TARGET:1696, CN_SOURCE:1695, CN_DESCRIPTION: }"

and i need to break it between each { }

i've tryed this below but without results.

select distinct replace(col1,'}', char(10) + char(13)) as col1 from table1

Upvotes: 0

Views: 59

Answers (2)

Ilyes
Ilyes

Reputation: 14928

First , switch from grid to text results , then run the query :

SELECT REPLACE (col1, '}', '}' + CHAR(13) ) as col1
FROM table1;

Upvotes: 0

Gordon Linoff
Gordon Linoff

Reputation: 1269853

I would just write this as:

select replace(col1, '}', '}
') as col1
from table1;

However, I think your version should also add in a newline.

Upvotes: 1

Related Questions