with cteDefault as (select row_number() over(partition by ConnectionID order by case when Name like '%~[|*|~]' escape '~' then 0 when Name = '|{[home]}|' then 1 else 2 end) as RowNum, ID from dbo.ConnectionHandbook)
update h
set IsDefault = 1
from cteDefault d
    inner join dbo.ConnectionHandbook h on h.ID = d.ID
where d.RowNum = 1;