|
The following
Microsoft SQL Server T-SQL database script in SSMS Query Editor uses recursive CTE to split a CSV list inline fast.
-- T-SQL delimited list splitter - split string list
DECLARE @CSV varchar(128) = 'Seattle Steel Structures,720 4th Avenue,,,Kirkland,WA,98233, 425-729-5600,425-729-5601'; ;WITH ctecsvsplit
AS (SELECT Element = Left(@CSV,NULLIF(Charindex(',',@CSV),0) - 1),
runningcsv = Stuff(@CSV + ',',1,Charindex(',',@CSV),'') UNION ALL SELECT Convert(VARCHAR(128),Left(runningcsv,Charindex(',',runningcsv) - 1)), Stuff(runningcsv,1,Charindex(',',runningcsv),'') FROM ctecsvsplit WHERE runningcsv <> '') SELECT Element FROM ctecsvsplit GO /* Element Seattle Steel Structures 720 4th Avenue Kirkland WA 98233 425-729-5600 425-729-5601
*/
|