Positively received questions [with] [tag] that [do not] contain [text]

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

declare @tagToSearch nvarchar(35) = '<' + ##tag:string## + '>';
declare @textToSearch nvarchar(max) = lower(##text:string##);
declare @include bit = iif(##includeText:string?yes## = 'yes', 1, 0);
declare @withTag bit = iif(##includeTag:string?yes## = 'yes', 1, 0);
declare @totalPosted bigint;

select
  Id as [Post Link],
  Score
from
  Posts
where
  PostTypeId = 1
  and
  (
    @withTag = 1 and charindex(@tagToSearch, Tags) > 0
    or
    @withTag = 0 and charindex(@tagToSearch, Tags) = 0
  )
  and
  (
    @include = 1 and charindex(@textToSearch, lower(Body)) > 0
    or
    @include = 0 and charindex(@textToSearch, lower(Body)) = 0
  )
  and
  DeletionDate is null
  and
  ClosedDate is null
  and
  Score >= 0
order by
  Score
desc

Enter Parameters

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