-1

I have a table like this

CREATE TABLE Employee
(
    [EmployeeId] int, 
    [EmployeeName] varchar(100), 
    [ClassId] nvarchar(MAX)
);

with sample data like this:

EmployeeId   EmployeeName   ClassId
-----------------------------------
   1         xyz           3,4,7
   2         abc           7,5,3

I want to get individual data from ClassId

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Does this answer your question? [Split comma separated string table row into separate rows using TSQL](https://stackoverflow.com/q/30920483/2029983) – Thom A Nov 03 '20 at 11:38
  • Does this answer your question? [T-SQL split string](https://stackoverflow.com/q/10914576/2029983) – Thom A Nov 03 '20 at 11:39
  • Does this answer your question? [STRING_SPLIT in SQL Server 2012](https://stackoverflow.com/questions/46902892/string-split-in-sql-server-2012/46902994) – Thom A Nov 03 '20 at 11:39
  • 1
    How to split a string, in SQL Server, is probably to most over asked question in the SQL Server related tags; there are literally 100's of duplicates. Of course, the real solution, however, if fix your design. – Thom A Nov 03 '20 at 11:40

1 Answers1

-1

You can split the retrieved data by comma to get an array of comma separated items. Other than that, I don't think there's a clean direct way of doing it with SQL.

  • Would be nicer if you write code or code hints – Useme Alehosaini Nov 03 '20 at 14:20
  • The user is saying that the goal the OP has isn't possible in SQL, @UsemeAlehosaini, so it would make no sense to supply code. The answer, however, is completely untrue as demonstrated by the multitude of duplicate posts out there; all with solutions or closed as a duplicate of one that does. – Thom A Nov 03 '20 at 16:42