Link to home
Start Free TrialLog in
Avatar of susnewyork
susnewyorkFlag for United States of America

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 -  ?

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

Open in new window



For example, if a string looks like this after the update script is run:

DD-TheValue-The.Location.Name

I would like it to show:

DD-TheValue
Avatar of Aneesh
Aneesh
Flag of Canada image

Do you have more sample values, in the sample you have mentioned, you are selecting everything before the second '-' thats confusing
Avatar of susnewyork

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.
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect, thanks.