March 16, 2012 at 8:59 am
I have a table which has a column called Name, which contains the name of our vendors. The data format in this column is lastname, firstName. For example, Smith, John or Lee, Mathew.
How can I split out the last name and first name separately?
Thanks,
March 16, 2012 at 9:03 am
QQ-485619 (3/16/2012)
I have a table which has a column called Name, which contains the name of our vendors. The data format in this column is lastname, firstName. For example, Smith, John or Lee, Mathew.How can I split out the last name and first name separately?
Thanks,
if every field has a comma, something like this would work...it's simply doing substrings based ont eh charindex of the comma.
SELECT
substring([FULLNAME],1,CHARINDEX(',',[FULLNAME]) -1) AS LASTNAME,
substring([FULLNAME], CHARINDEX(',',[FULLNAME]) + 1,250) AS FIRSTNAME
FROM SOMETABLE
Lowell
March 17, 2012 at 12:13 pm
CELKO (3/17/2012)
First you need to read a book on basic data modeling;"name" is an attribute property, which means your column should have been "vendor_name" instead.
it really sounds like the OP inherited the problem and is trying to resolve it. what happens then joe? what if the OP is reading the book and looking at the inherited database and thinking how he can fix the "Problem".
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply