 	<cfquery name="p_raw" datasource="prod">
 		select * from ssrch_field_doc
 	</cfquery>
-
 	<cfquery name="allterms" dbtype="query">
 		select id cfvar from d_raw
 		union
 		select cf_variable cfvar from p_raw
 	</cfquery>
+	<cfloop query="allterms">
+		<cfquery name="p" dbtype="query">
+			select * from p_raw where cf_variable='#cfvar#'
+		</cfquery>
+		<cfquery name="c" dbtype="query">
+			select * from d_raw where id='#cfvar#'
+		</cfquery>
+		<cfif p.recordcount gt 0>
+			<cfset in_docs=1>
+		</cfif>
+
+		<cfif c.recordcount gt 0>
+			<cfset in_code=1>
+		</cfif>
+		<cfset used_in_frm="">
+		<cfset rawtags="">
+
+		<cfquery name="u_f" dbtype="query">
+			select distinct frm from c
+		</cfquery>
+		<cfloop query="u_f">
+			<cfset used_in_frm=listappend(used_in_frm,frm,';')>
+		</cfloop>
+
+		<cfquery name="u_t" dbtype="query">
+			select distinct rawtag from c
+		</cfquery>
+		<cfloop query="u_t">
+			<cfset rawtags=listappend(rawtags,rawtag,';')>
+		</cfloop>
+
+
+
+		<cfquery name="d_raw" datasource="uam_god">
+			insert into temp_doc_merge (
+				cfvar,
+				in_code,
+				in_docs,
+				CATEGORY,
+				CONTROLLED_VOCABULARY,
+				DATA_TYPE,
+				DEFINITION,
+				DISPLAY_TEXT,
+				DOCUMENTATION_LINK,
+				PLACEHOLDER_TEXT,
+				SEARCH_HINT,
+				SQL_ELEMENT,
+				SPECIMEN_RESULTS_COL,
+				DISP_ORDER,
+				SPECIMEN_QUERY_TERM,
+				used_in_frm,
+				rawtags
+			) values (
+				'#cfvar#',
+				'#in_code#',
+				'#in_docs#',
+				'#p.CATEGORY#',
+				'#p.CONTROLLED_VOCABULARY#',
+				'#p.DATA_TYPE#',
+				'#p.DEFINITION#',
+				'#p.DISPLAY_TEXT#',
+				'#p.DOCUMENTATION_LINK#',
+				'#p.PLACEHOLDER_TEXT#',
+				'#p.SEARCH_HINT#',
+				'#p.SQL_ELEMENT#',
+				'#p.SPECIMEN_RESULTS_COL#',
+				'#p.DISP_ORDER#',
+				'#p.SPECIMEN_QUERY_TERM#',
+				'#used_in_frm#',
+				'#rawtags#'
+			)
+		</cfquery>
+	</cfloop>
+	<cfquery name="r" datasource="uam_god">
+		select * from temp_doc_merge order by cf_var
+	</cfquery>
+
+	<cfdump var=#r#>
+
+
+	<!-----
+
+
+	 Name								   Null?    Type
+ ----------------------------------------------------------------- -------- --------------------------------------------
+
+
+
 
 	<cfdump var=#allterms#>
 

	select id || ' :: ' || frm from temp_doc_id_raw order by id;

		select id || ' :: ' || frm from temp_doc_id_raw where id not in (select cf_variable from ssrch_field_doc@db_production) order by id;

---->
<cfinclude template="/includes/_header.cfm">

			<cfdump var=#p#>
		</cfif>
	</cfloop>
	---->
</cfoutput>
</cfif>

