Query hint to force SQL to use a temporary table in a CTE query?
Hi,
is it possible to tell SQL Server to create a temporary table by itself when I'm using a CTE in my query?
I have a query starting with a CTE where I group by my record, then another recursive CTE use the first CTE and finally my select statement like:
with cte as (select a,b,c,row_number() ... from mytable group by a,b,c)
, cte2(select .... from cte A where rownum =1
union all select ... from cte B inner join cte2 C on ......
select * from cte2
this query is very very slow, but if I store the first CTE into a temporary table and then cte2 consume my temp table rather than the CTE, the query is very fast.
creating the temp table took 10sec and the select took 20sec
while the initial query didnt return anything after 2minutes!!!
so what can I try to do to have the query running in less than 30sec without creating the temp table first?
is there a query hint which can be used to tell SQL Server to convert the CTE into a temp table?
as I have a lot of query to manage, I want to simplify my model without relying in temporary tables every time I suffer this issue...
thanks.
What is your SQL Server version?
There is no hint to materialize results of cte into a temp table, so the solution you tried is the best you can have.
I think the idea of materializing CTE into a temp table was already proposed on Connect. Try searching for this and vote.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles
Similar Messages
-
Appropriate use of temporary table - or can pivot approach be used?
I am relatively new to pl/sql. My problem is that I need to return one row of data (joining several tables, including a 1-many), but with a varying number of columns (from single values returned from the 1-many table), and record types cannot be dynamically defined or modified (such as with adding columns).
I am not sure if pivoting the many table would work, because the range of values returned (albeit not expected to realistically exceed a dozen) do not fall within a small set.
Would dynamically generating SQL to create a temporary table with the requisite number of columns be the best approach? Then I could select all the data into the table, iterate through the results from the 1-many and populate into the columns, and then select * from the temp table for the return resultset.
Specifics: There is a document table which has a 1-many table containing the CC's for that document. Only one row will ever be returned from the master doc table, and 0-n rows from the CC table. There could be no CC's for the doc, or there could be any number. I need to be able to return all the columns from the document table PLUS the CC's as if they were all one row in a table.
So example of a return row might be a doc with n # of cc's
DOC_ID | DOC_TYPE | DOC_OWNER | <etc> | CC_1 | CC_2 | ... | CC_n
or a doc with all its fields and no cc's
DOC_ID | DOC_TYPE | DOC_OWNER | <etc>
So I am thinking the pl/sql would have to
1. declare the SQL statement to create a temporary table
2. declare the SQL statement to insert data into the temporary table
3. declare the SQL statement to query data from the temporary table
4. fetch the count of CC's based on doc id from the CC table
5. use that count to loop and
1. append columns onto the sql that creates the temporary table
2. append columns onto the sql that will query the temporary table
6. query the CC's table and read the values into an array
7. use the count again to loop and dynamically create the insert statement for the temporary table, using the values from step 6
8. execute the insert statement
9. query the temporary table using the sql generated in step 5.2 and return that rowset
HUGE thanks to anyone who can provide input on this. I know it's not a new problem, I am just unsure of the best approach to the solution.It's not that I require a single SQL statement to do this; in fact I expected to have to execute at least 2 in the procedure to accomplish the goal. The problem I am running into is that I need to return a dynamic number of columns, based on the number of entries in the 1-many table.
I'm guessing if I can look up the number of rows in the 1-many table that I need to pivot before I actually do the pivot, I will be able to use this technique?
The reasoning for all this can be summed up in one word: legacy. The row is being sent back to a legacy component which only takes that one single row of data. Currently, we are only limited to 3 CC entries and are expanding the system to allow >3, hence the 1-many table. However, the legacy component isn't able to handle anything more complex than that one row. Our clients will be able to change their definitions easily to expand from CC1, CC2, CC3 to however many they want to use. However, changing to multiple rows wouldn't be an option because it would incur too much complexity. -
When to use global temporary tables?
which are the probable situations when one can think of using global temporary tables?
In my experience, most often GTTs are used by developers from other RDBMSs who have become used to needing 'intermediate tables' created on the fly to hold data while they 'loop and commit to free locks'.
These developer may not have had enough exposure to Oracle's concurrency model and therefore use the 'other' concurrency model as the basis for an application port - usually followed up by a call to the forum for assistance in performance tuning. <g>
That said, legitimate uses for GTTs include staging or scrubbing table for data transport or preparation, eg: ETL into a warehouse, when the intermediate data is
a) reproducible (therefore does not need to be logged); and
b) the results of the intermediate operation, but not the source, are stored in permanent tables.
Some developers also use GTTs to hold the equivalent to a 'temporary materialized view' specifically for complex reporting purposes. -
Using Global Temporary Table in OBIEE 11
Hi,
THe requirement is to run a database function before the report runs. This Function accepts 5 parameters (Presentation Variable) and populates a GTT Global Temporary Table.
This GTT is configured in presentation Layer.
Issue:
1. Created a dummy report which returns only one row and called the fucntion using "Evaluate" in this.
2. Created 2nd report using GTT Columns.
All these 2 reports placed on dashboard and Presentation variable are set in the prompt. The first one runs correctly and populate the "Regular Table". Means when I create a regular table instead of GTT I can see the correct record. But if I change it to GTT then the data does not get populated in this table.
Any Inputs?
RegardsHI,
If you are using a GTT, you need to run the function which populates the GTT before OBI server executes the select query on that table.
In your case, the OBI server is executing the select query from the table before the data is populated in the table.
In order to force the BI server to run the query after the GTT is populated, you need to specify the condition in the connection pool settings under the connection scripts tab.
In the execute before query, enter your physical query which runs the function to populate the GTT.
Hope this helps !
Thanks,
Vineeth -
Use two temporary tables to assign "color" to data results
Hi, Everyone... Here's a rundown of what I'm trying to do, any help is obviously appreciated...
Example Tables and Data:
I have 5 Courses, each course has 2 assignments.
with Courses as (
select 100 courseID from dual union all
select 200 from dual union all
select 300 from dual union all
select 400 from dual union all
select 500 from dual
), Assigns as (
select 'test100' name, 100 courseID from dual union all
select 'test100', 100 from dual union all
select 'test200', 200 from dual union all
select 'test200', 200 from dual union all
select 'test300', 300 from dual union all
select 'test300', 300 from dual union all
select 'test400', 400 from dual union all
select 'test400', 400 from dual union all
select 'test500', 500 from dual union all
select 'test500', 500 from dual
select assigns.name, assigns.courseID from courses
inner join assigns on assigns.courseID = courses.courseIDI need each assignment to get a color assigned to it according to it's courseID. So my theory is that I'd have a temporary table with a list of colors; each courseID would get assigned a color but my question is how do I assign each courseID a color without anything to join the temporary table on? Once each courseID has a color, I'd join in Assigns so that each assignment has a color associated with it according to it's courseID.
--Color table with 6 colors
with Colors as (
select 'red' color from dual union all
select 'blue' from dual union all
select 'yellow' from dual union all
select 'green' from dual union all
select 'purple' from dual union all
select 'teal' from dual
)I have a previous post about this but I didn't explain it well and to link to it would probably add confusion to this question... happy to delete that post if someone recommends it.
Thanks for any help! Running Oracle 11g.Hi,
939920 wrote:
I don't have the ability to store the courseID with the colors...Then get it, or have someone with the ability make the change for you.
Is the problem that you have more than 6 courses, but you want to color-code them with only 6 colors, and there's no telling which courses may be included in the results of a given query?
If so, you can do somehting like this:
WITH colors AS
SELECT 'red' AS color_name FROM dual UNION ALL
SELECT 'blue' FROM dual UNION ALL
SELECT 'yellow' FROM dual UNION ALL
SELECT 'green' FROM dual UNION ALL
SELECT 'purple' FROM dual UNION ALL
SELECT 'teal' FROM dual
, colors_plus AS
SELECT color_name
, ROW_NUMBER () OVER (ORDER BY NULL) - 1 AS color_id
, COUNT (*) OVER () AS color_cnt
FROM colors
, course_assigns AS
SELECT a.name
, a.courseid
, DENSE_RANK () OVER (ORDER BY a.courseid) AS course_num
FROM assigns a
INNER JOIN courses c ON a.courseid = c.courseid -- If needed
SELECT ca.name
, ca.courseid
, cp.color_name
FROM course_assigns ca
JOIN colors_plus cp ON cp.color_id = MOD ( ca.course_num
, cp.color_cnt
;Typical output:
AME COURSEID COLOR_
test100 100 blue
test100 100 blue
test200 200 yellow
test200 200 yellow
test300 300 green
test300 300 green
test400 400 purple
test400 400 purple
test500 500 teal
test500 500 tealIt would be better if you could create a real table like colors_plus.
If there are more than 6 distinct courses in the output, then 2 or more courses may be coded with the same color, but no color will be used N times (N>1) until all colors have been used N-1 times.
The assignment of courses to coolors is arbitrary. Depending on how fancy you want to make this, you might want to do something more complicated. For example, say you have 2 courses with 10 rows each, and 5 courses with 1 row each. The query above will have to assign the same color to 2 differenct courses, and it might assign the color 'blue' to the 2 courses with 10 rows each. The query above can be modified, if necessary, to assign the colors in order of frequency, to guarantee that the two 10-row courses get different colors, and that the colors are more evenly distibuted in general. I'll leave this as an execise. (Hint: use the frequency in the ORDER BY clause of DENSE_RANK. To get the frequency, use the analytic COUNT function in a sub-query. Why do you need a sub-query? Discuss amongst yourselves.) -
PL/SQL block to create temporary table + load via cursor for loop
Assume I have a table that contains a subset of data that I want to load into a temporary table within a cursor for-loop. Is it possible to have a single statement to create the table and load based on the results of the fetch?
I was thinking something like:
Declare CURSOR xyz is
CREATE TABLE temp_table as
select name, rank, serial number from
HR table where rank = 'CAPTAIN'
BEGIN
OPEN xyz
for name in xyz
LOOP
END LOOP
What I see wrong with this is that the table would be created multiple times which is why this syntax is not acceptable. I'd prefer not to have to define the temporary table then load in two sepearte SQL statements and am hoping a single statement can be used.
Thanks!What is the goal here?
If you're just going to iterate over the rows that are returned in a cursor, a temporary table is unnecessary and only adds complexity. If you truly need a temporary table, you would declare it exactly once, at install time when you create all your other tables. You'd INSERT data into the temp table and the data would only be visible to the session that inserted it.
Justin -
Java Error while Using GLobal Temporary Tables
Hi,
Am having a global temporary table in my application with ON COMMIT DELETE ROWS option.
I use it in a procedure to remove previous records, populate new ones and return a ref cursor
Am calling this procedure from a java bean. In this call, the procedure gets executed successfully but when i try to access the RefCursor Object, I get an SQL Exception that the object no longer exists.
Here are some inputs for reference:
My DB Call:
cstmt = myConn.prepareCall ("{ call MYPACKAGE.GTT_PROCEDURE(?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?)}");
My RefCursor Access:
rsRuleSet = (ResultSet)cstmt.getObject(11);
The SQLException:
java.sql.SQLException: ORA-08103: object no longer exists
Please note that the SQLException shown as per Java Stack trace is on the line with the RefCursor Access
If anybody has any idea, then do reply
Thanks in Advance,
PiyushA couple of thoughts...
Have you tried calling this procedure from PL/SQL to verify that the REF CURSOR returned is valid?
Is your Java application set to autocommit, or do handle transactions yourself. If the container is handling transactions, it may committing as soon as the stored procedure finishes running, which would clear your temp table.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Requirement :
To generate stock movement report for certain selected items.
Background :
A Form is created with data block (tmp_item_master - a global temporary table)
when_new_form_instance :
inserting into tmp_item_master from item_master and then execute_query on tmp_item_master block.
User selects certain items using check box provided.
Now tmp_item_master is updated for ch_select_flag_yn = 'Y' for selected items
and commit.
Calling report from form(using run_product()).
Now the main query in report, is joined with tmp_item_master where ch_select_flag_yn = 'Y'
Here, we are unable to see the report for any item. As the global temporary table data is not visible in the report session.
How to resolve this problem ?
Note : global temporary table created with ON COMMIT PRESERVE ROWS
Thanking you,
From praful.
nullHi,
You are using 'ON Commit Delete Rows' . Instead of Use ' ON COMMIT PRESERVE ROWS'
The ON COMMIT DELETE ROWS clause indicates that the data should be deleted at the end of the transaction.
CREATE GLOBAL TEMPORARY TABLE my_temp_table (
column1 NUMBER,
column2 NUMBER
) ON COMMIT DELETE ROWS;
In contrast, the ON COMMIT PRESERVE ROWS clause indicates that rows should be preserved until the end of the session.
CREATE GLOBAL TEMPORARY TABLE my_temp_table (
column1 NUMBER,
column2 NUMBER
) ON COMMIT PRESERVE ROWS;
Edited by: Mrucha on Nov 26, 2012 6:06 AM -
Using Global Temporary Table in Discoverer.
Hi All
I am currently working on a Disco report, where I am initializing a package at the disco condition level which inserts data in to a Global Temporary Table.
The global temporary table will be having data based on the parameter entered by the user. But the problem occurs when we are trying to use the same GTT in the select statement as shown below. The desktop is not giving me the otuput but the GTT is getting populated with data.
see below
SELECT bla1,
bla2,
bla3
FROM GTT (global temp table)
WHERE 1= PACKAGE.FUNCTION(par1, par2, par3...) <- here we are trying to insert into GTT based on the paramenters passed.
Can you please suggest how this can be achieved. Or is there any way to trigger the insertion in to GTT other than the calling it in the condition level.
Thanks
ArunHi,
You cannot use a GTT like this because you cannot write and read from the GTT using a single SQL statement. You must either have the insert in a separate worksheet and tell the users to run this worksheet first, or you wrap it all up in a table function called from within a view. The table function can then insert and select from the GTT using two statements.
Which method is best depends on what you are trying to do and why you want to use a GTT.
Rod West -
How to use Oracle temporary table and verify if it exists
1. I got two errors on the following code.
ORA-06550: line 13, column 4:
PLS-00428: an INTO clause is expected in this SELECT statement
ORA-06550: line 17, column 3:
PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
2. Can I include this code in the create view statement?
Thanks ahead, I am new to oracle dev world.
===========================================================
DECLARE
l_count NUMBER;
BEGIN
select count(*)
into l_count
from all_tables
where table_name like 'TEMP_SHOW_STAFF_2%';
if l_count > 0 then
select * from TEMP_SHOW_STAFF_2;
else
create global temporary table TEMP_SHOW_STAFF_2
(employee_id Number,
last_name varchar(10),
first_name varchar(10),
salary_amount varchar(10))
on COMMIT delete rows;
end if;
END;The PL/SQL User's Guide will have much more information, but as a quick example (new_dept is an empty table with the same structure as the DEPT table in the SCOTT schema).
1 declare
2 -- Create the type & declare a variable of that type
3 type dept_arr_typ is table of dept%rowtype;
4 dept_arr dept_arr_typ;
5 begin
6 -- Populate the type in memory
7 select *
8 bulk collect into dept_arr
9 from dept;
10 -- Manipulate the data
11 for i in 1..dept_arr.count
12 loop
13 select 'foo'
14 into dept_arr(i).dname
15 from dual;
16 end loop;
17 -- Write the data back
18 for i in 1..dept_arr.count
19 loop
20 insert into new_dept( deptno, dname, loc )
21 values( dept_arr(i).deptno, dept_arr(i).dname, dept_arr(i).loc );
22 end loop;
23* end;
SCOTT @ nx102 Local> /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01
SCOTT @ nx102 Local> select * from new_dept;
DEPTNO DNAME LOC
10 foo NEW YORK
20 foo DALLAS
30 foo CHICAGO
40 foo BOSTONOf course, for this sort of thing, we could do everything in a single SQL statement
INSERT INTO new_dept( deptno, dname, loc )
SELECT deptno, 'foo', loc
FROM dept;Collections can be handy if you need to apply a bit more conditional logic, though.
Justin -
How i can force sql developer to show just tables of HR schema ?
In sql developer we can filter the tables that it shows under table node ,
how i can force it just to show tables of HR schema ?
ThanksSee my post in your other thread (How i can deal with DB schema in SQL developer ?
In this case, you let only the HR user in the right panel. -
Hello all,
This is my first time on the forums, so please bear with me. Im also a somewhat novice SQL coder but I have a question that I feel might be best answered my the more advanced folks on this forum.
I have 3 tables, a user table, a group table and a membership table.
Say:
user_table
+-------------------+
| user_PK |
| Id |
| Name |
| Description |
+-------------------+
Group_table
+-------------------+
| group_PK |
| Id |
| Name |
| Description |
+-------------------+
Group_members
+----------------------+
| group_members_PK |
| Group_ID |
| Member_ID |
| Member_type |
+----------------------+
The group_ID is linked to the Group_table.ID and the Member_ID can be either linked back to the group_table or user_table depending on the value of member_type.
It is possible to have nested groups, and each level of nesting can have users as well not just nested groups. Sort of how the windows group nesting model works.
I would like to end up with being able to have output that lists only users, their descriptions and their nested group path if any.
If you need more clarification please let me know. I know this maybe a simple thing, but Im unsure how to do it. Thanks in advance.>> This is my first time on the forums, so please bear with me. I am also a somewhat novice SQL coder but I have a question that I feel might be best answered my the more advanced folks on this forum. <<
Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. There is no generic “id”, “name, etc. in RDBMS. Tables have to have a key,
but we do not put “_pk” on the name. Read a copy of https://www.simple-talk.com/books/sql-books/119-sql-code-smells/ so you will stop tibbling and other bad practices.
You should follow ISO-8601 rules for displaying temporal data. We need to know the data types, keys and constraints on the table.
Avoid dialect in favor of ANSI/ISO Standard SQL. And do not draw ASCII pictures! They do not compile.
>>The group_id is linked [sic] to the group_table.id [sic] And the member_id can be either linked [sic] back to the group_table or user_table depending on the value of member_type. <<
RDBMS has no links; that was in network databases in the 1970's. No wonder you want to use recursive CTEs; they are cursors
>> It is possible to have nested groups, and each level of nesting can have users as well not just nested groups. Sort Of how the windows group nesting model works. <<
Then you should use a nested sets model. Since you did not post sample data, DDL or correct specs, Google it.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Can i Use two qery hints in one SQL(Oracle)?
Hi,
Can i Use two Query hints in one SQL(Oracle)? USE_HASH and No_Merge
Thanksuser10916886 wrote:
Can I use like
/*+ USE_HASH(X,Y) NO_MERGE(X) */
will this work?Not really: NO_MERGE relates to mergeable views, not base tables. So whilst the USE_HASH may result in a hash join between the tables X and Y, USE_MERGE will be ignored for X.
As hoek says, however, HINTs should be a last resort only, and if they're to be used at all you're best to stay with those that don't involve explicit objects, like ALL_ROWS, FIRST_ROWS_10, etc.
user10916886 wrote:
Im my database, if i don't use query hints. The expalin plan uses Nested loops, hence the query takes a lot of time.You would be better trying the ALL_ROWS hint here, instead of USE_HASH.
Edit
The optimizer, however, will have chosen NESTED LOOPs where it did because it believed that to be the most efficient data retrieval path with the information that it had to hand. So, if your statistics are comprehensive and up-to-date, yet the optimizer is continually opting for the less efficient plan, there's something else wrong, and HINTs are only masking that problem in the short-term. -
Can intermedia be used to index the results of a query
The objective is to search for a key word in the results from two different tables got by a jointed query
Or, you could try something like
select ...
from contextIndexedTable
where contains(textColumn, 'keyword') > 0
and rowid in
(select rowid from contextIndexedTable
where contains(textColumn, 'origquery') >0)
Should work, but not sure how it will perform. You could also place the rowids
from the original query into a temporary table and modify the query above to join to that first-level table instead of re-running the query. That may perform better.
If your original query is all text, you can
simply extend the text query:
(originalquery) AND (newquery)
but I get the sense that the original query involves structured conditions. -
How to Create a Temporary Table with SQL Server
I know you can create a temporary table in SQL Server 2000, but not quite sure how to do it in CFMX 7, i.e., does the SQL go inside a <CFQUERY dbtype="query"> tag?
I'm pulling the main set of records from an Oracle server (1st data source), but it does not contain employee names, only employee IDs. Since I need to show the employee name along with the Emp ID, I'm then pulling a list of "current" employee names from a SQL Server (2nd data source), which is the main database on our CF server.
I've got a QofQ that works fine, except it only matches EmpIDs that exist in both result sets. Employees who are no longer employed, don't match, and don't display. Since I can't do a LEFT OUTER JOIN with a QofQ, what I need to do is get the records from the Oracle server into the SQL Server. Preferably in a temporary table.
I was hoping if I could get those Oracle records written to a temp table on the main SQL Server, in same database as the Employee Name table, I could then write a normal <CFQUERY> that uses a LEFT OUTER JOIN.
I think I could probably write a Stored Procedure that would execute the SQL to create the temporary table, but am trying to avoid having to write the SP, and do it the simplest way.
This query will be a program that can be run hundreds of times per day, with a form that allows users to select date ranges, locations, and other options. That starts the queries, which creates the report. So I just need the temp table to exist only until all the SQL has run, and the <CFOUTPUT> has generated a report.
If the premise is right, I just need some help with the syntax for creating a SQL Server temp table, when you want to write records to it from an external data source. I'm trying the following, but getting an error:
<CFQUERY name="ITE_Temp" datasource="SkynetSQL">
CREATE TABLE #MyTemp
( INSERT INTO #MyTemp
ITE2.TrueFile char (7) NOT NULL,
ITE2.CountOfEmployee int NULL,
ITE2.DTL_SUBTOT decimal NULL,
ITE2.EMPTYPE char (3) NULL,
ITE2.ARPT_CD char (3) NULL
</CFQUERY>
So I actually created a permanent table on the SQL Server, and wrote the below SQL, which does work, and does write the records to table. I can then write another CFQUERY with a LEFT OUTER JOIN, and get all the records, including those that don't have matching employee name:
<CFQUERY datasource="SkynetSQL">
<CFLOOP index="i" from="1" to = "#ITE2.RecordCount#">
INSERT INTO ITE_Temp
(FullFile,
EmployeeCount,
DTL_Amount,
EmployeeType,
station)
VALUES ('#ITE2.TrueFile[i]#',
#ITE2.CountOfEmployee[i]#,
#ITE2.DTL_SUBTOT[i]#,
'#ITE2.EMPTYPE[i]#',
'#ITE2.ARPT_CD[i]#')
</CFLOOP>
</CFQUERY>
But, I hate to have to create a table and physically write to it. For one, it seems slower, and doing it in temp would be in memory, and probably much faster, correct? Is there some way to code the above, so that it does something similar, but in a TEMPORARY TABLE? If I can figure out how to do this, I can pull data from multiple data sources and servers, and using SQL Server temp tables, work with the data as if it was all on the same SQL Server, and do some cool reports.
Everything I've done for the past few years, has all been from data from a single source, whether SQL Server, or another server. Now I need to start writing reports where data can come from 3 or 4 different servers, and be able to do joins (inner and outer). Thanks for any advice/help. Much appreciated.
GaryWhile waiting to hear back, I was able to write the query results from an outside Oracle server, to a table on the local SQL Server, and do the LEFT OUTER JOIN required for the final query and report to work. That was with this syntax:
<CFQUERY name="AddTableRecords" datasource="MyTable">
TRUNCATE TABLE ITE_Temp
<CFOUTPUT query="ITE2">
INSERT INTO ITE_Temp
(FullFile,EmployeeCount,DTL_Amount,EmployeeType,station)
VALUES
('#TrueFile#', #CountOfEmployee#, #DTL_SUBTOT#, '#EMPTYPE#', '#ARPT_CD#')
</CFOUTPUT>
</CFQUERY>
However, I was not able to write to a temporary table AND read the results. I got the syntax to run to write the above results to a temporary table. But when I tried to read and output the results from the temp table, I got an error. Also, it wouldn't take the single "#" (local) only the global "##" table var, using this syntax. Note that if I didn't have the DROP TABLE in the beginning, the 2nd time you run this query, you get an error telling you the table already exists.
<CFQUERY name="ITE_Temp2" datasource="MyTable">
DROP TABLE ##MyTemp2
CREATE TABLE ##MyTemp2
FullFile char (7) NOT NULL,
EmployeeCount int NULL,
DTL_Amount decimal NULL,
EmployeeType char (3) NULL,
station char (3) NULL
<CFOUTPUT query="ITE2">
INSERT INTO ##MyTemp2 VALUES
'#ITE2.TrueFile#',
#ITE2.CountOfEmployee#,
#ITE2.DTL_SUBTOT#,
'#ITE2.EMPTYPE#',
'#ITE2.ARPT_CD#'
</CFOUTPUT>
</CFQUERY>
So even though the above works, I could use some help in reading/writing the output. I've tried several things similar to below, but they don't work. It't telling me ITE_Temp2 does not exist. It's not easy to find good examples of creating temporary tables in SQL Server.
<CFQUERY name="QueryTest2" datasource="SkynetSQL">
SELECT *
FROM ITE_Temp2
</CFQUERY>
<CFOUTPUT query="ITE_Temp2">
Output from Temp Table<br>
<p>FullFile: #FullFile#, EmployeeCount: #EmployeeCount#</p>
</CFOUTPUT>
Thanks for any help/advice.
Gary.
Maybe you are looking for
-
Trouble connecting consoles to tv
This only talked about Wireless. We just bought a Nintendo Wii and a Nintendo Component Cable (Red/Blue/Green and Red/White cables) to connect. We connected the Wii console to the Cable box using the component cable, but when we switched the TV to Co
-
Trying to connect a home computer using Outlook 2013 to my business Exchange server 2010.
I have a new Dell XPS with Outlook 2013 installed and the native email client installed. I was able to enter in my exchange 2010 credentials to the native email client and it worked. when I try to enter the credentials for Outlook 2013 I received an
-
PGI Should get block - without material cost in material master
Hi All, The scenario is we want to show error message while doing PGI if the material does not have any material cost in material master. How it is possible? Will we able to do with standards? Scenario: Material cost is nil in the material master, sy
-
Simple question on aligning video and audio
I am new to this and am using the Cs4 trial. I have placed a video in video 1 timeline and it has audio that appears in the audio one line. Now I have also inserted a plain audio file from the sound board of the same event into audio track two. I wo
-
I am looking for a way in our forms to have all the words be in all capitals. So when a customer is filling out the fillable areas and tab to the next box a script turns all of the text to capitals. I am using Adobe Pro X