temporary-tables

SQL Server, temporary tables with truncate vs table variable with delete

I have a stored procedure inside which I create a temporary table that typically contains between 1 and 10 rows. This table is truncated and filled many times during the stored procedure. It is truncated as this is faster than delete. Do I get any performance increase by replacing this temporary table with a table variable when I suffer...

Global Temporary Table "On commit delete rows" functionality discrepancy.

I have a global temporary table. I shall call him GTT, for that was it's initials. My GTT never hurt anyone, and did everything I bade of it. I asked my GTT to delete rows on commit. This is a valid function in the creation script of my GTT in oracle. I wanted to be able to have different users see GTT with their own data, and not the ...

How to duplicate all data in a table except for a single column that should be changed.

I have a question regarding a unified insert query against tables with different data structures (Oracle). Let me elaborate with an example: tb_customers ( id NUMBER(3), name VARCHAR2(40), archive_id NUMBER(3) ) tb_suppliers ( id NUMBER(3), name VARCHAR2(40), contact VARCHAR2(40), xxx, xxx, archive_id NUMBER(3...

How to dump temporary MySQL table into a file?

Is there a way to create a dump/export/save a temporary MySQL table into a file on disk(.sql file that is, similar to one that is created by mysqldump)? ...

Is it wise to use temporary tables?

Hi guys, We have a mySQL database table for products. We are utilizing a cache layer to reduce database load, but we think that it's a good idea to minimize the actual data needed to be stored in the cache layer to speed up the application further. All the products in the database, that is visible to visitors have a price attached to t...

Temporary tables in sql server?

hi, I have a doubt Why Should we use temporary table is there any special thing in temporary table and where should we use the temporary tables. Can you please explain me or any reference thank you. ...

Dropping Sql Temp tables from Vb.Net

Hi guys, I have a vb.net app , and I am creating and dropping temp tables. I just want to know whether the temp tables created programatically from some client app will get dropped automatically with dispose of application or we should have to drop it explicitly by code. I need to be sure that all tables will get dropped when I close m...

In SQL Server 2008 ,is it possible to disable auto drop of global temp table

Hi question1 : I am using global temp tables in SQL Server 2008 but once my connection is closed this temp is dropped is there any way to disable auto drop Question2 : If two connections are accesstion same global temp table and another connection is trying to delete that global temp table, does SQL Server handles this synchroni...

SQL Server 2008 - Update a temporary table

Hello, I have stored procedure in which I am trying to retrieve the last ticket completed by each user listed in a comma-delimited string of usernames. The user may not have a ticket associated with them, in this case I know that i just need to return null. The two tables that I am working with are defined as follows: User ---- UserNam...

Child sProc cannot reference a Local temp table created in parent sProc

On our production SQL2000 instance, we have a database with hundreds of stored procedures, many of which use a technique of creating a #TEMP table "early" on in the code and then various inner stored procedures get EXECUTEd by this parent sProc. In SQL2000, the inner or "child" sProc have no problem INSERTing into #TEMP or SELECTing data...

Why SQL2008 debugger would NOT step into a certain child stored procedure

I'm encountering differences in T-SQL with SQL2008 (vs. SQL2000) that are leading me to dead-ends. I've verified that the technique of sharing #TEMP tables between a caller which CREATES the #TEMP and the child sProc which references it remain valid in SQL2008 See recent SO question. My core problem remains a critical "child" stored pro...

Stored Procedure: Reducing Table Data

Hi Guys, A simple question about Stored Procedures. I have one stored procedure collecting a whole bunch of data in a table. I then call this procedure from within another stored procedure. I can copy the data into a new table created in the calling procedure but as far as I can see the tables have to be identical. Is this right? Or i...

ways to avoid global temp tables in oracle

We just converted our sql server stored procedures to oracle procedures. Sql Server SP's were highly dependent on session tables (INSERT INTO #table1...) these tables got converted as global temporary tables in oracle. We ended up with aroun 500 GTT's for our 400 SP's Now we are finding out that working with GTT's in oracle is conside...

Where Does Temporary Tables Gets stored in sql server.

Where does temporary tables gets stored in database. I want to drop a temporary table if it already exists. I can do this for securable table by querying at information schema but i done know where temporary tables are stored ...

MySQL temp table issue

Hi folks! I'm trying to use temp tables to speed up my MySQL 4.1.22-standard database and what seems like a simple operation is causing me all kinds of issues. My code is below.... CREATE TEMPORARY TABLE nonDerivativeTransaction_temp ( accession_number varchar(30), transactionDateValue date) ) TYPE=HEAP; INSERT INTO nonDerivativ...

SQL Server CTE referred in self joins slow

Hello, I have written a table-valued UDF that starts by a CTE to return a subset of the rows from a large table. There are several joins in the CTE. A couple of inner and one left join to other tables, which don't contain a lot of rows. The CTE has a where clause that returns the rows within a date range, in order to return only the row...

SQL Server - Temporary vs. Physical Tables

Hi All, A movement is afoot in my place of employ to move away from using #temp tables and instead to use permanent physical tables with SPIDs. Whenever one would have previously INSERTed INTO a #temp table, now an INSERT INTO dbo.MyPermanentTable (SPID, ...) VALUES (@@SPID, ...) is required - together with a bunch of DELETE FROM dbo.M...

How to add 2 temporary tables together.

If I am creating temporary tables, that have 2 columns. id and score. I want to to add them together. The way I want to add them is if they each contain the same id then I do not want to duplicate the id but instead add the scores together. if I have 2 temp tables called t1 and t2 and t1 had: id 3 score 4 id 6 score 7 and t2 had: ...

Can SELECTING FROM one empty temp table in SQL cause the results to be empty?

Here is my problem. I am creating 4 temp tables to count specific types of boxes and an employee's hours. Given a beginning date and ending date we want to know total boxes of each type (1, 2, and 3) and their total hours worked in that time period. All works perfectly if there is at least one of each type, but if only two types are pres...

How to create temporary tables in Hibernate?

Goal Invoke a CREATE TEMPORARY TABLE statement in Hibernate without using native SQL. That means using HQL or Hibernate APIs only. Save objects to the temporary table. Invoke a stored procedure which makes use of existing tables and the temporary table. DROP the temporary table when finished. (I know it's not necessary, but I think it'...