﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / Substring Query to pull firstname and lastname out of one column / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sun, 19 May 2013 16:40:53 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Substring Query to pull firstname and lastname out of one column</title><link>http://www.sqlservercentral.com/Forums/Topic1398447-392-1.aspx</link><description>That works great.   I had never seen that function scipt before.   I just had to then create a script to catch the firstname , lastname and initial based on the ID and item numbers into the columns I needed.   Thanks.</description><pubDate>Wed, 19 Dec 2012 09:39:54 GMT</pubDate><dc:creator>Jeff Sims-413169</dc:creator></item><item><title>RE: Substring Query to pull firstname and lastname out of one column</title><link>http://www.sqlservercentral.com/Forums/Topic1398447-392-1.aspx</link><description>well, one way is to use the delimitedSplit8K function to chop the string into bitesize peices.from there, you might need to cross apply, modifying the WHERE statement to limit it to teh data that's mostly correct.take alook at this example...you'll see how  the name is chopped into 2 or 3 pieces per ID, based on your sample data.[code]With mySampleData(Id,String)AS(SELECT 1,'HIST-AS-JEFFERY WINKEL-02/26/1976-07/06/2012' UNION ALLSELECT 2,'HIST-AS-JOSEPH WALDNER-07/07/1965-07/06/2012' UNION ALLSELECT 3,'HIST-AS-TERESA KLINE-10/09/1965-02/13/2012' UNION ALLSELECT 4,'HIST-HS-A. MARION GROSETH-11/10/1931-01/19/2009' UNION ALLSELECT 5,'HIST-HS-AARON ALFRED-07/06/1967-06/02/2010')select   mySampleData.*,  ByDashes.*,  BySpaces.*from mySampleDataCROSS APPLY dbo.DelimitedSplit8K(mySampleData.String,'-') ByDashesCROSS APPLY dbo.DelimitedSplit8K(ByDashes.Item,' ') BySpacesWHERE ByDashes.ItemNumber = 3 --the 3rd dash group has the values we want to further split by spaces[/code]{edit}here's the article containing the DelimitedSplit8K funcrtion:[url]http://www.sqlservercentral.com/articles/Tally+Table/72993/[/url]</description><pubDate>Wed, 19 Dec 2012 08:39:09 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>Substring Query to pull firstname and lastname out of one column</title><link>http://www.sqlservercentral.com/Forums/Topic1398447-392-1.aspx</link><description>I Have a table with a field called name that is formated as the examples below.  I need to pull the firstname as firstname  and the lastname as lastname and the DOB as DOB.  DOb is the first date in the field.I am having a hard time getting it to pull between the -.       Basic format: these will all have the same number of '-' but there could be an extra initial in the name as the sample below shows for A. Marion Groseth.  how can I get it to get past those names with the extra initial as well?   HIST-AS-JEFFERY WINKEL-02/26/1976-07/06/2012HIST-AS-JOSEPH WALDNER-07/07/1965-07/06/2012HIST-AS-TERESA KLINE-10/09/1965-02/13/2012HIST-HS-A. MARION GROSETH-11/10/1931-01/19/2009HIST-HS-AARON ALFRED-07/06/1967-06/02/2010</description><pubDate>Wed, 19 Dec 2012 08:28:16 GMT</pubDate><dc:creator>Jeff Sims-413169</dc:creator></item></channel></rss>