troubleshooting Question

Seperate comma deliminated values

Avatar of XGIS
XGISFlag for Australia asked on
Microsoft SQL ServerMicrosoft SQL Server 2008SQL
13 Comments1 Solution488 ViewsLast Modified:
Hello Experts,

the solution to this problem may be simple but at the moment it is not forthcoming;

I have a script to separate a comma deliminator column i need to be able to use the value output to filter another view.

I initially attempted to use it as a nested select statement but it was falling over at the 'Create Unique Clustered Index '

so I attempted to create view, where the view runs and displays the results; SSME will not save it.

SELECT IDENTITY(INT) AS Number
   INTO Numbers
   FROM sysobjects s1
  CROSS JOIN sysobjects s2

CREATE UNIQUE CLUSTERED INDEX Number_ind
   ON Numbers(number)
   WITH IGNORE_DUP_KEY) 

SELECT dbo.Licence.LicencingID, dbo.Licence.PropertyID, dbo.Licence.TAG,
       LTRIM(RTRIM(SUBSTRING( dbo.Licence.TAG, Number, 
       CHARINDEX( ',', dbo.Licence.TAG + ',', Number ) - Number ))) as Value
  FROM dbo.Licence
 INNER JOIN Numbers
    ON SUBSTRING( ',' + dbo.Licence.TAG, Number, 1 ) = ',' 
where Number <= Len(dbo.Licence.TAG) + 1

Some guidance would be most appreciated.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 13 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros