SQL Server 2008 R2 - Strip most all text but keep specific text . . .

kouts1
kouts1 used Ask the Experts™
on
Hi guys,

I have a column with HTML text that I need to remove everything but keep only  "Assigned To:"  and everything after that. Is that possible?
Example data: "Assigned To:" is near the end.
Admit Decision to Inpatient:  VB?  NO Medicine  -  Dutsi BehmTest  Flag  Value    Units    Ref. Range Status   Lab  Address  BEDREQUESTAdmitted To: Black Team CleanBEDREQUESTAssigned To: G6E-111111

Open in new window


I need to end up with:  Assigned To: G6E-111111

thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database and Application Developer
Commented:
declare @MyString nvarchar(max);
Set @MyString ='Admit Decision to Inpatient:  VB?  NO Medicine  -  Dutsi BehmTest  Flag  Value    Units    Ref. Range Status   Lab  Address  BEDREQUESTAdmitted To: Black Team CleanBEDREQUESTAssigned To: G6E-111111'

Select SUBSTRING ( @MyString ,CHARINDEX ( 'Assigned To:' ,@MyString) , 100 );

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial