Knowledge: SQL to Lookup Secondary Taxonomy Level
Back
Knowledge
Title*SQL to Lookup Secondary Taxonomy Level
ManualReporting
Created09/04/2019
DetailInput of this data action must be named InValue and come from root taxonomy setting.
if ISNULL(@InValue,'') = ''
BEGIN
SET @InValue = 'All'
END
DECLARE @TaxonomyID as int = 1;
DECLARE @ParentEntryID as nvarchar(max) = '';
DECLARE @Pos as int;
SELECT @pos = CHARINDEX('|', @InValue) ;
SELECT @ParentEntryID = SUBSTRING(@InValue, @pos+1, len(@InValue)-1);
IF ISNUMERIC(@ParentEntryID) = 0
BEGIN
SET @ParentEntryID = -1
END
Select ' - All - ' as Name, 'All' as Value UNION
Select Name, Value + '|' + RTRIM(LTRIM(CAST(ID as nvarchar(max)))) as Value FROM TaxonomyEntries WHERE ISNULL(ParentEntryID,0) = @ParentEntryID
and TaxonomyID=@TaxonomyID
Order By Name
Additional Manual Locations
Administration | Data Actions | SQL |