sql - Give group of rows unique identifier TSQL -
quick question, have table column identifier grouping of rows. illustration grouping of rows recording customers transactions, each row has customers reference.
what trying accomplish give grouping of rows new unique identifier, can study on anonymously.
what have tried
update dbo.[t_health] set code = 'abc' + cast(rand() varchar(50)) si.custref= si.custref
many thanks!
to create new unique identifier, utilize newid()
function
with anonymousid ( select distinct custref, newid() newid t_health) update dbo.t_health set code = ai.newid dbo.t_health h bring together anonymousid ai on h.custref = ai.custref
sql sql-server tsql
No comments:
Post a Comment