May 14, 2014 at 7:47 am
Hi Guys,
I am struck with some fires logic, which i am not able to figure out 🙂
I have a comma separator field,
For Example, the field values is
Annual Holiday, Annual Leave - David Hornby,
Solution: I want to retrieve the first comma string (Annual Holiday) and remove the rest value from the field and display.
It should be Just Annual Holiday
May 14, 2014 at 7:57 am
I found the solution..
LEFT([field], CHARINDEX(',', [field]) - 1)
:):):)
Thanks:-):-):-):-)
May 15, 2014 at 7:39 am
farooq.hbs (5/14/2014)
I found the solution..LEFT([field], CHARINDEX(',', [field]) - 1)
:):):)
Thanks:-):-):-):-)
That will work if you are certain that your source string will ALWAYS contain at least one comma. If you cannot guarantee that then you will need to test for the presence of a comma and return the original string if there is none.
May 15, 2014 at 8:06 am
crmitchell (5/15/2014)
farooq.hbs (5/14/2014)
I found the solution..LEFT([field], CHARINDEX(',', [field]) - 1)
:):):)
Thanks:-):-):-):-)
That will work if you are certain that your source string will ALWAYS contain at least one comma. If you cannot guarantee that then you will need to test for the presence of a comma and return the original string if there is none.
There's no need for a great validation process, just append a comma to the field.
LEFT([field], CHARINDEX(',', [field] + ',') - 1)
May 15, 2014 at 5:31 pm
Luis Cazares (5/15/2014)
crmitchell (5/15/2014)
farooq.hbs (5/14/2014)
I found the solution..LEFT([field], CHARINDEX(',', [field]) - 1)
:):):)
Thanks:-):-):-):-)
That will work if you are certain that your source string will ALWAYS contain at least one comma. If you cannot guarantee that then you will need to test for the presence of a comma and return the original string if there is none.
There's no need for a great validation process, just append a comma to the field.
LEFT([field], CHARINDEX(',', [field] + ',') - 1)
Careful now... concatenation is what killed the cat on some of the earlier splitters. It will probably be faster to do the ISNULL/NULL IF thing to change a 0 to 8000.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 15, 2014 at 6:08 pm
Jeff Moden (5/15/2014)
Luis Cazares (5/15/2014)
crmitchell (5/15/2014)
farooq.hbs (5/14/2014)
I found the solution..LEFT([field], CHARINDEX(',', [field]) - 1)
:):):)
Thanks:-):-):-):-)
That will work if you are certain that your source string will ALWAYS contain at least one comma. If you cannot guarantee that then you will need to test for the presence of a comma and return the original string if there is none.
There's no need for a great validation process, just append a comma to the field.
LEFT([field], CHARINDEX(',', [field] + ',') - 1)
Careful now... concatenation is what killed the cat on some of the earlier splitters. It will probably be faster to do the ISNULL/NULL IF thing to change a 0 to 8000.
It's good to know. I usually don't work with strings that long. I wouldn't expect this scenario to be one of those cases.
May 15, 2014 at 6:35 pm
Agreed. It's not going to matter with such short strings as those on this post. It was more of a tip just in case you need to do something similar with longer strings. I should have made that more clear.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply