susnewyork
asked on
Print the portion of a string past a special character
Hi,
How would I go about editing this script to update my column with only the portion of the string after a special character such as . or - ?
For example, if a string looks like this after the update script is run:
DD-TheValue-The.Location.N ame
I would like it to show:
DD-TheValue
How would I go about editing this script to update my column with only the portion of the string after a special character such as . or - ?
update TABLEdata
set emailGrouping=case when employeestatus!='Terminated' and emailGrouping is null and DepartmentCode like '2%'
then substring(DepartmentDescription, 8, 45)
When employeestatus!='Terminated' and emailGrouping is NOT null and DepartmentCode like '2%'
then emailGrouping+', '+substring(DepartmentDescription, 8, 45) else emailgrouping
end
For example, if a string looks like this after the update script is run:
DD-TheValue-The.Location.N
I would like it to show:
DD-TheValue
Do you have more sample values, in the sample you have mentioned, you are selecting everything before the second '-' thats confusing
ASKER
That's basically what I need.
Another example of what would need to be excluded would be this:
DD-2ndValue.LocationDate
I would need:
DD-2ndValue from that string.
Another example of what would need to be excluded would be this:
DD-2ndValue.LocationDate
I would need:
DD-2ndValue from that string.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect, thanks.