dLight dLight - 2 months ago 10
SQL Question

Line break or Carriage return in a Delimited Field in Sql

I have an email column that stores a minimum of more than 10 emails in a row. Now, I want to write a query that puts each email on a separate line, e.g:

hay@line.com
u@y.com
live.gmail.com


How do write this?

Answer

Use Replace()

select replace(MyEmailField, '<CurrentDelimeter>', char(13)) as NewEmail
from MyTable