I have a table in Excel. This table I load to SQL Server through SSIS. In the table is column TEXT that contains multiple sentences in one cell separated by enter spaces (alt + enter). My table looks like this:
| NAME | ID | TEXT |
| ------------ | ------------ | ------------ |
| JOHN SMITH | 125 | TEXT TEXT TEXT |
But sometimes I have in column TEXT more enter spaces without text, like this:
NAME | ID | TEXT |
---|---|---|
JOHN SMITH | 125 | TEXT TEXT TEXT |
I need to remove excess line breaks but keep enter space after each TEXT.
1条答案
按热度按时间3ks5zfa01#
In basic case you can use
REPLACE
function for replace duplicatesBut this query replace ONLY duplicates, so in case 3 or more duplicates you need repeat the query. For automate this you can use PROCEDURE like next:
Test this solution on https://sqlize.online/sql/mssql2019/3ce3f73e8d27862fd7d268523a4a4a14/