Scudboy
asked on
Transact SQL challenge - Trim data after a special character
I am trying to return a string up to a certain character, and cannot figure out what I should be using. This may be a newbie question...
Basically, a varchar(255) column named COMMENT has the following value:
'Working on a solution to get this to appear_NOT THIS'
When I select that column I would like the result to be
'Working on a solution to get this to appear'
So effectively trimming everything to the right of the _ (underscore).
Is that even possible?
Basically, a varchar(255) column named COMMENT has the following value:
'Working on a solution to get this to appear_NOT THIS'
When I select that column I would like the result to be
'Working on a solution to get this to appear'
So effectively trimming everything to the right of the _ (underscore).
Is that even possible?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi dba2dba -
The issue with using the statement above is that it assumes the removed text will be consistent. This won't be the case.
In this example -
We'd want to remove everything after the underscore (or # sign, or whatever would work in this capacity).
The issue with using the statement above is that it assumes the removed text will be consistent. This won't be the case.
In this example -
COMMENTCOLUMN
I would like this to appear_NOT THIS
Working on a solution to get this to appear_NOT THIS
This is what we'd want to show up_NOT THIS SECTION
This is good_this is bad and we do not want it to show up in the return list of value
We'd want to remove everything after the underscore (or # sign, or whatever would work in this capacity).
ASKER
MWVisa1 nailed it - thanks much for the assistance, split points per request!
ASKER
COMMENTCOLUMN
I would like this to appear_NOT THIS
Working on a solution to get this to appear_NOT THIS
This is what we'd want to show up_NOT THIS SECTION
This is good_this is bad and we do not want it to show up in the return list of values.