Recently, someone asked me a question. They were storing comma separated values in a column of the table. This table was getting populated from some source via SSIS package. Here is the simplified version of the problem, I was presented with.
- DECLARE @t TABLE
- (
- UserID INT,
- Certs VARCHAR(8000)
- )
- INSERT @t VALUES (1,'B.E.,MCA, MCDBA, PGDCA'), (2,'M.Com.,B.Sc.'), (3,'M.Sc.,M.Tech.')
- SELECT UserID,
- LTRIM(RTRIM(m.n.value('.[1]','varchar(8000)'))) AS Certs
- FROM
- (
- SELECT UserID,CAST('<XMLRoot><RowData>' + REPLACE(Certs,',','</RowData><RowData>') + '</RowData></XMLRoot>' AS XML) AS x
- FROM @t
- )t
- CROSS APPLY x.nodes('/XMLRoot/RowData')m(n)

Samantha LevonPosted Sep 16, 2019, 1:26 PM
No you didn't. This query is from SQLauthority website
SubashPosted Mar 17, 2017, 9:35 PM
Is this will work? why don't we use bulitin string fuctions?