I've looked this up in the knowledge database and it *seemed* to make sense but just isn't happenening correctly so thanks in advance for assistance.
Issue is there is a FirstName, LastName MI string that I'm trying to extract from a file in order to verify memberIDs.
The column name is simply "Name" and is NVARCHAR(250).
I've used the below -- doesn't matter to me if it's declared or just part of a SELECT though would be good to reuse -- but I'm not correctly doing so as is -- the result is giving me 1000s of NULL row values irrespective of what used.
1 declare @a nvarchar(250)
select substring(@a,CHARINDEX(',', @a)+1,CHARINDEX(' ', @a,CHARINDEX(',', @a)+2)-CHARINDEX(',', @a)) + ' ' +
substring(@a,0,CHARINDEX(',', @a)) as UpName
2. SELECT SUBSTRING(ColumnName,CHARINDEX('(',ColumnName)+1,CHARINDEX(')',ColumnName)-(CHARINDEX('(',ColumnName+1))
+ ' '+
SUBSTRING(ColumnName', 1, CHARINDEX(',',ColumnName)-1)
substring(Name, charindex('(', Name), charindex(')', Name) - charindex('(', Name)) as Name FROM table