Find targets for duplicate posts


Please login or register to vote for this query.

(click on this box to dismiss)

Each duplicate question has up to three other questions as the non-duplicate posts. This query finds the posts that duplicate questions point to. It mostly works, but no guarantees.


Q&A for community managers, administrators, and moderators

create table #Dupes (Dupe INT, Targets VARCHAR(255))
insert into #Dupes
select top 200 PostId as [Post Link],
    -- Grab text from after the first '[' to the first ',' or ']'
              charindex('[', Text)+1,
              CASE WHEN charindex(']', Text) < charindex(',', Text) THEN
                   charindex(']', Text)
              ELSE charindex(',', Text) END
              - charindex('[', Text) - 1) as FirstDupeTarget
from PostHistory h
where PostHistoryTypeId = 10
and Comment in (1, 101)
order by h.CreationDate desc

select Dupe as [Post Link], cast(Targets as INT) as [First Target Post Link]
from #Dupes

Enter Parameters

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