Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select emrID, displayName
- into #ControlTable
- from emrs
- declare @emrid int
- declare @counter int = 1
- declare @displayName nvarchar(max)
- while exists (select * from #ControlTable)
- begin
- select top 1 @displayName = displayname
- from #ControlTable
- group by displayname
- update emrs set groupId = @counter where @displayName = displayname
- delete #ControlTable
- where @displayName = displayname
- set @counter = @counter + 1
- end
- drop table #ControlTable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement