SELECT 'A; AB. A; ABC '
Want
A; AB. ABC
CodePudding user response:
Data on this field according to the fixed delimiters, go together again after heavy, advice, write a function to call this fieldIf you found out the data is used on a front end to program, it is best to processing in the program
CodePudding user response:
The CREATE TABLE # T
(
Id INT IDENTITY (1, 1),
A VARCHAR (100)
)
INSERT INTO (A) VALUES (' # T A; AB. A; ABC '), (' A; AB. A; ABCA; AB. A; ABC '), (' AA; AA; BB; BB ')
SELECT id, STUFF ((SELECT '; '+ value FROM string_split (A,'; ')
GROUP BY value
FOR XML PATH (')), 1, 1, ' ') FROM # T B
DROP TABLE # T