sql - Loop and assign non-unique GUID to sets of values? -
i'm sure in easy one, can't go past conceptualization syntax: have table of features 1 named feature may populate several rows e.g:
[name], [guid] fred, null fred, null fred, null tom, null mary, null mary, null mary, null mary, null
what i'd assign 1 guid per name:
fred, {3b26af27-9d42-481c-a8c8-be1819dccda5} fred, {3b26af27-9d42-481c-a8c8-be1819dccda5} fred, {3b26af27-9d42-481c-a8c8-be1819dccda5} tom, {ee64b706-def0-4e5c-a5fd-0c219962042e} mary, {fd158f90-9705-4a18-b82c-baca29441401} mary, {fd158f90-9705-4a18-b82c-baca29441401} mary, {fd158f90-9705-4a18-b82c-baca29441401} mary, {fd158f90-9705-4a18-b82c-baca29441401}
declare @tmp table ( name varchar(30), guid uniqueidentifier ) insert @tmp select x.name, newid() (select distinct name mytable) x update mytable set guid = tmp.guid mytable t inner bring together @tmp tmp on t.name = tmp.name
sql sql-server sql-server-2008 guid
No comments:
Post a Comment