views:

36

answers:

1

I have a string that always reads as follows:

re-assigning LastName, FirstName re-assigned the order to LastName, FirstName (Administrator) Reason Code: Reassign order Comment:

The name is always diffent but I only want to return the LastName, Firstname part on the first occurence so right after re-assigning. The spaces and everything is exactly how it appears when it is printer except the Lastname, FirstName is normally a name of course.

Any Ideas?

Thanks!

+1  A: 
declare @x varchar(max)

set @x = 're-assigning LastName,  FirstName re-assigned the order to LastName, FirstName (Administrator)  Reason Code: Reassign order  Comment:   '

select SUBSTRING(@x,14,PATINDEX('%re-assigned%',@x)-15) 

Returns "LastName, FirstName"

Is that what you need?

Martin Smith
No the LastName, Firsname is actually a name and I need to extract that name....
That's what my code does.
Martin Smith