Tag 'Ownership' - Taxonomist


Please login or register to vote for this query.

(click on this box to dismiss)

Identify who first created a tag, and how many questions use it.

Arts and Crafts Meta

Q&A about the site for artists and crafters

create table #tago (
TagId int,
TagName NVarchar(25),
TagCount int,
Owner int,
Display NVarchar(40),
Awarded NVarchar(3),
cpost int,
RevisionLink NVarchar(250))

declare @tid int,
        @tname NVarchar(25),
        @tcnt int,
        @phid int,
        @rcnt int,
        @uid int,
        @dname NVarchar(40),
        @awarded int,
        @guid uniqueidentifier,
        @pid int;

declare TAGS cursor for select Id, TagName, "Count" from Tags

open TAGS

fetch next from TAGS into @tid, @tname, @tcnt
while @@FETCH_STATUS = 0
   print 'processing tag ' + @tname;
   select @phid = Min(Id)
   from PostHistory
   where PostHistoryTypeId in (3, 6)
     and Text like '%<' + @tname + '>%'

   select @pid = PostId,
          @uid = UserId,
          @dname = UserDisplayName
   from PostHistory
   where Id = @phid

   select @rcnt = count(distinct RevisionGUID)
   from PostHistory
   where PostId = @pid
     and Id <= @phid
     and PostHistoryTypeId < 10
   select @awarded = count (Id)
   from Badges
   where UserId = @uid
     and Name = 'Taxonomist'
     and @tcnt >= 50
   insert into #tago
   select @tid,
          case when @awarded = 0 then '' else 'Yes' end,
          'site://revisions/' + cast(@pid as nvarchar) 
             + '/' + cast(@rcnt as nvarchar) + '|Revision ' 
             + cast(@rcnt as nvarchar)
   fetch next from TAGS into @tid, @tname, @tcnt

  Owner [User Link],
  Display [Name],
  cpost as [Post Link],
  RevisionLink as [Revision]
from #tago

Enter Parameters

Switch to main site
loading Hold tight while we fetch your results