Edits by a specific users to the tag-wikis (multisite)


Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers Meta

Q&A about the site for Drupal developers and administrators

declare @sql nvarchar(max)

create table #result (site sysname
                    , hostname sysname
                    , pid int
                    , tagname nvarchar(35)  
                    , comment nvarchar(400)
                    , creationdate datetime)

select @sql = N'insert into #result' + STRING_AGG(concat(N'
select ''', name ,N''' as site
     , ''',hostname ,N'''
     , p.id
     , t.tagname     
     , ph.comment
     , ph.creationdate
     from ', quotename(name), N'.dbo.posts p inner join', 
       quotename(name), N'.dbo.tags t on (t.wikipostid = p.id or t.excerptpostid = p.id) inner join ',
       quotename(name), N'.dbo.posthistory ph on (ph.PostId=p.id) and (ph.CreationDate >= ''##Date1?2022-01-01##'')and (ph.CreationDate <= ''##Date2?2022-07-01##'') inner join',
       quotename(name), N'.dbo.users u on ph.UserId=u.id and u.AccountId=',CAST(##AccountId:int## as nvarchar),
    'where (p.PostTypeId IN (##types?4,5##))
union all')
from (select convert(nvarchar(max),name) name
    -- , convert(nvarchar(max),sitename)  sitename
    -- , meta
    -- , domain
     ,  concat( 
        -- based on an idea from Glorfindel 
        -- https://meta.stackexchange.com/a/321181
        (case sitename
        WHEN 'Audio' THEN 'video'
        WHEN 'Beer' THEN 'alcohol'
        WHEN 'CogSci' THEN 'psychology'
        WHEN 'Garage' THEN 'mechanics'
        WHEN 'Health' THEN 'medicalsciences'
        WHEN 'Moderators' THEN 'communitybuilding'
        WHEN 'Photography' THEN 'photo'
        WHEN 'Programmers' THEN 'softwareengineering'
        WHEN 'Vegetarian' THEN 'vegetarianism'
        WHEN 'Writers' THEN 'writing'
        WHEN 'Br' THEN 'pt'
        WHEN 'Mathoverflow' THEN concat((meta+'.'), sitename)
        ELSE case when sitename = domain then null else sitename end
        end +'.')
        , (case 
           when sitename <> 'mathoverflow' then (meta+'.') 
           else null 
        , (case 
           when sitename <> 'mathoverflow' then concat((domain + '.'), 'com') 
           else 'net' 
        ) hostname
from (
select name
, case parsename(name,1) 
  when 'Meta' then parsename(name,2)
  else parsename(name,1) 
  end [sitename]
, case parsename(name,1) 
  when 'Meta' then 'meta'
  else null
  end [meta]
  , coalesce(parsename(name,3), parsename(name,2)) [domain]
from sys.databases
where (database_id > 5)
--- and (name like '%.Meta')
) dbs
) dbsall

exec (@sql)

select top(##num?500##)
  site, hostname, 
  concat('https://',hostname,'/posts/',CAST(pid AS varchar),'/revisions') AS [Revisions],
from #result
order by creationdate DESC

Enter Parameters

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