I have 2 columns in my table, called TaskSet and SkillsSelected.
The sample data as follow:
TaskSet | SkillsSelected
--------------------------------------------------
SK000001, SK000004, SK000002 | SK000001, SK000002, SK000003
SK000002 | SK000002, SK000003, SK000004
As you can see it’s using comma to separate the data. I want a query that will give me the record that is not from the TaskSet that is not exist in the SkillsSelected so in this case will return:
SK000003
SK000003, SK000004
First, implement the CLR Split() function that you get in the Samples on the SQL 2005 installation media.
Alternatively, you could do it using a table of numbers, which would work sufficiently well, and doesn’t force you to turn on CLR.
[Edit] Edited to include t.* in the list. This should really be changed to use the PK of t, or some other identifying feature.
[Edit] Sorry – had them the wrong way around.
And now that the question has changed, let’s address the concatenation too: