I have a colleague who, with her eyes closed, and both arms severed, can code circles around anyone else here. I try to learn as much as a can from her, but she's not exactly "availble" to train someone like me. I'm not claiming the code below is some glorious example of her skills, but i would love someone to walk me through what the code below is doing. I think of it as the Rosetta Stone for myself, as understanding something like that which is below would allow me to understand much more. In fact, i'll provide anyone who can provide me a coherent walk through for this code, a batch of my famous Jack Daniels chocolate chip cookies. that's right, cookies made with the best Tennessee sipping whiskey ever.SELECT [InmateKey],[InputDate],LTRIM(RTRIM(LEFT([Alias],CHARINDEX(',',[Alias])-1))) AS [Alias],DOB,SSN,UNIQUEKEY FROM #ALIAS WHERE CHARINDEX(',',[Alias]) <> 0 AND CHARINDEX(' ',LTRIM(RTRIM(LEFT([Alias],CHARINDEX(',',[Alias])-1)))) <> 0 AND CHARINDEX(' ',LTRIM(RTRIM(SUBSTRING([Alias],CHARINDEX(',',[Alias])+1,300)))) <> 0 UNIONSELECT [InmateKey],[InputDate],CASE WHEN RIGHT(LTRIM(RTRIM(SUBSTRING([Alias],CHARINDEX(',',[Alias])+1,300))),1) = ',' THEN LTRIM(RTRIM(LEFT(LTRIM(RTRIM(SUBSTRING([Alias],CHARINDEX(',',[Alias])+1,300))),LEN(LTRIM(RTRIM(SUBSTRING([Alias],CHARINDEX(',',[Alias])+1,300))))-1))) ELSE LTRIM(RTRIM(SUBSTRING([Alias],CHARINDEX(',',[Alias])+1,300))) END AS [Alias],DOB,SSN, SCADMIN.dbo.fnsc_GetUniqueID(NEWID()) AS UNIQUEKEY FROM #ALIAS WHERE CHARINDEX(',',[Alias]) <> 0 AND CHARINDEX(' ',LTRIM(RTRIM(LEFT([Alias],CHARINDEX(',',[Alias])-1)))) <> 0 AND CHARINDEX(' ',LTRIM(RTRIM(SUBSTRING([Alias],CHARINDEX(',',[Alias])+1,300)))) <> 0edit: fixed long lines