How to separate emails by semicolon in SQL Server?

Asked

Viewed 243 times

0

I have a column that has several emails separated by semicolons, I would like to know how to separate these emails and insert separately in another table. In the image below is more detailed.

inserir a descrição da imagem aqui

1 answer

3


Just break the emails using STRING_SPLIT and then an Index with the result of SELECT, thus:

INSERT INTO EMAILS(emails)
SELECT A.value AS EMAIL_QUEBRADO
FROM EMAIL X
OUTER APPLY STRING_SPLIT(X.email, ',') AS A
  • Thank you, I tested it here and it worked ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.