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.
| Author |
Topic |
|
HomerJ
Starting Member
21 Posts |
Posted - 2009-03-12 : 17:40:45
|
| I need to try to find an easy way to strip the 'tail' off of a field value. I have a several thousand record table, and the PropName field has a list of names, some of which have an additional "FMR:name" tag on the end.Example:McDonaldsBurger King FMR:Dairy QueenWhat I'd like to do is something like:Update DataTable SET PropName = Replace(PropName,'FMR%','')Where I simply delete/replace with null any PropName with a tail. So in my example, afterward it would be:After updateMcDonaldsBurger KingAny advice would be appreciated. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-03-12 : 17:43:53
|
[code]UPDATE DataTableSET PropName = CASE CHARINDEX(' FMR', PropName) WHEN 0 THEN PropName ELSE LEFT(PropName, CHARINDEX(' FMR', PropName) - 1) END[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|