questions tagged with [tag], but not by any of [tag list]

0

Please login or register to vote for this query.

(click on this box to dismiss)

Tridion Meta

Q&A about the site for Tridion developers and administrators

declare @tag nvarchar(35) = ##tag:string##;
declare @list nvarchar(max) = ##list:string##;

declare @tagsToExclude table ( 
  tag nvarchar(35) COLLATE SQL_Latin1_General_CP1_CS_AS 
);

declare @pos int = 0;
declare @nxt int = 0;
declare @len int = len(@list);

while @pos <= @len
  begin
  
    set @nxt = charindex(',', @list, @pos);
    set @nxt = iif(@nxt = 0, @len + 1, @nxt);
  
    insert into @tagsToExclude 
    values (
      '%<' + trim ( substring( @list, @pos, @nxt - @pos ) ) + '>%'
    );
      
    set @pos += @nxt - @pos + 1;
  
  end;
  
select row_number() over (order by Tags), * from
(
select distinct
  Id as [Post Link],
  Tags
from
  Posts
where
  charindex('<' + @tag + '>', Tags) > 0
  and
  PostTypeId = 1
  and
  not exists(select 1 from @tagsToExclude where Tags like tag)
) dist

--select * from @tagsToExclude

Enter Parameters

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