How to group data and write it's group id for each row?
;WITH cteA
AS(SELECT  Name,GroupID,
        DENSE_RANK () OVER(ORDER BY Name) AS New_GroupID
     FROM #T)


UPDATE  cteA
SET GroupID  = New_GroupID


Now , depending of your system , this could take a few seconds or more.
You can split the update , to do in chunks. 
Something like A-G , then from G to M ... and you can add , in the DENSE_RANK  something like MaxGroupID + DENSE_RANK () OVER(ORDER BY Name) AS New_GroupID