<!--- Create the SQL build scripts so that we can reuse it within the different CFQuery tags. ---> <cfsavecontent variable="strBuildSQL"> DECLARE @data TABLE ( trans_id INT, tag_id INT ); <!--- Populate data. ---> INSERT INTO @data ( trans_id, tag_id )( SELECT 1, 1 UNION ALL SELECT 1, 2 UNION ALL SELECT 2, 1 UNION ALL SELECT 2, 2 UNION ALL SELECT 2, 3 UNION ALL SELECT 3, 3 UNION ALL SELECT 3, 4 ); </cfsavecontent>