Code search within a tag

1

Please login or register to vote for this query.

(click on this box to dismiss)

based of https://meta.stackoverflow.com/questions/363747/please-enable-symbol-search

Genealogy and Family History Meta

Q&A about the site for expert genealogists and people interested in genealogy or family history

declare @search nvarchar(200) = ##code:string##
declare @tag nvarchar(35) = ##tag:string?r##

set @search = replace(@search,'[', '[[]');
set @search = replace(@search,'_', '[_]');
set @search = replace(@search,'%', '[%]');

print @search

;with tagposts as (
select p.id 
from posts p
inner join posttags pt on pt.postid = coalesce(p.parentid, p.id)
inner join tags t on t.id = pt.tagid
where tagname = @tag
)

select  top 50
       -- count(*)
       p.id as [Post Link]
     , p.posttypeid
     , p.score
     , p.creationdate
     , p.tags
from tagposts tp
inner join posts p on tp.id = p.id
where p.body like concat('%<pre><code>%', @search, '%</code></pre>%')
order by p.score desc

Enter Parameters

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