February 25, 2015 at 12:54 pm
I need to change a column so it only brings Lastname, Firstname and not Lastname, Firstname and middleInitial
like Mark, Kenn and not Mark, Kenn A
Any Ideas?
February 26, 2015 at 3:16 am
Hi,
Can you please provide some more details?
what exactly you required in output with some sample data
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
February 26, 2015 at 4:22 am
The column is storing the entire name? Up front, that's a bad design.
You could use the LEFT function in combination with the CHARINDEX function to find the location of the comma in the string and bring everything back to the left of the comma. All the string manipulation functions are listed here.
But, your best bet would be to normalize that structure so that you have Last Name in one column, First Name in another and Middle Names in a third.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
February 26, 2015 at 5:32 am
Names are hard to work with. What if you have Billy Joe Doe? Their first name is Billy Joe so you do not want to leave off Joe.
February 26, 2015 at 5:59 am
+1 to both Grant and djj. Names are notoriously difficult. Any part of the name can contain spaces or punctuation of some sort, so splitting them is going to be brutal and won't be foolproof.
February 26, 2015 at 10:31 am
Yeah, it was tricky. So, I tweaked the Join condition. Saved !
February 26, 2015 at 11:23 am
Wait, so that means it wasn't a column, but part of a result set?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply