Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Extracting Multiple names from a field

Author  Topic 

bholmstrom
Yak Posting Veteran

76 Posts

Posted - 2013-11-08 : 13:11:36
Good afternoon, I have a table that has several fields that contain multiple user names sepearted by a ";". I am trying to extract all of the names into one column so I can then compare it against our active directory.

It would be nice if there was list of names, not duplicated.

Example:

Row 1
Field1 'Mary Beth Underwood'
Field2 'Bryan Flinstone'
Field3 'Mary Beth Underwood;George Test'
Field4 'Hank String'

Row 2
Field1 'Gary Strong'
Field2 'Barney Ted;George Bishop; Hank String'
Field3 'Liz What;Ted Notime'
Field4 'Henry Franks'

What I would like to see is a list like this:

Barney Ted
Bryan Flinstone
Gary Strong
George Bishop
George Test
Hank String
Henry Franks
Liz What
Mary Beth Underwood

Thank you for your always prompt responses

Bryan Holmstrom

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2013-11-08 : 13:50:10
If you scroll to the bottom you will see an answer with multiple way to do this:
http://stackoverflow.com/questions/5722700/how-do-i-split-a-delimited-string-in-sql-server-without-creating-a-function
Go to Top of Page
   

- Advertisement -