trifecta2k
asked on
Insert query into temp tables using Coldfusion
I have a query and I need to insert into a temp table.
The query is created by reading an excel file. Let's call it query1.
I would like to do something like this:
I know that doesn't work and I know I can do something like this:
But is there a better way without using the cfloop? This is a large import and we need to be more efficient.
The query is created by reading an excel file. Let's call it query1.
I would like to do something like this:
CREATE TABLE ##hazardousProductInfo
(
id int NOT NULL identity(1,1)
, item_number VARCHAR(20) NULL
, hazardous_material_description VARCHAR(255) NOT NULL DEFAULT ''
, hazardous_material_class VARCHAR(25) NOT NULL DEFAULT ''
);
INSERT INTO ##hazardousProductInfo
SELECT * FROM query1
I know that doesn't work and I know I can do something like this:
CREATE TABLE ##hazardousProductInfo
(
id int NOT NULL identity(1,1)
, item_number VARCHAR(20) NULL
, hazardous_material_description VARCHAR(255) NOT NULL DEFAULT ''
, hazardous_material_class VARCHAR(25) NOT NULL DEFAULT ''
);
<cfloop query="#query1#">
INSERT INTO ##hazardousProductInfo (
item_number
, hazardous_material_description
, hazardous_material_class)
VALUES (
'#column1#'
, '#column2#'
, '#column3#'
);
</cfloop>
But is there a better way without using the cfloop? This is a large import and we need to be more efficient.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yeah, it's very simple to use and wicked fast in comparison to individual inserts.
Glad it helped!
Glad it helped!
ASKER