Finding Query Exports and Filters by Name
Need to find all queries that use a particular filter or export? This will search for query filters and exports with "round" in the filter name.
SELECT qp.[query]
ย ย ,q.[name]
ย ย ,q.[folder]
ย ย ,qp.*
FROM [query.part] qp
INNER JOIN [query] q
ย ย ON q.id = qp.query
ย ย ย ย AND q.[archived] = 0
WHERE 1 = 1
ย ย --AND qp.[type] = 'filter'
ย ย AND qp.[source_type] <> 'arrange'
ย ย AND qp.[name] LIKE '%round%'
ย ย --Exclude inactive parts
ย ย AND qp.[active] = 1
ย ย --Exclude queries attached to old mailings
ย ย AND NOT EXISTS (
ย ย ย ย SELECT *
ย ย ย ย FROM [message.dataset] md
ย ย ย ย LEFT JOIN [message.mailing] mm
ย ย ย ย ย ย ON mm.[id] = md.[mailing]
ย ย ย ย ย ย ย ย AND (
ย ย ย ย ย ย ย ย ย ย mm.[activated] IS NULL
ย ย ย ย ย ย ย ย ย ย OR mm.[deactivated] < GETDATE()
ย ย ย ย ย ย ย ย ย ย OR mm.[archived] = 1
ย ย ย ย ย ย ย ย ย ย )
ย ย ย ย WHERE md.[query] = q.[id]
ย ย ย ย )
What if you want to find a certain export or filter from a Query Library? When you add an export or filter from a library, Slate might store the library query's GUID in theย [query.part].[xml]
, but there's no direct link to the original query part. Therefore, searching by name is usually the easiest approach.
No Comments