temporary-tables

Is there any other efficient way to use table variable instead of using temporary table

we are writing script to display banners on a web page where we are using temporary table in mysql procedure. Is there any other efficient way to use table variable instead of using temporary table we are using following code: -- banner location CURSOR -- DECLARE banner_location_cursor CURSOR FOR select bm.id as masterId, bm.secti...

Table variable poor performance on insert in SQL Server Stored Procedure

We are experiencing performance problems using a table variable in a Stored Procedure. Here is what actually happens : DECLARE @tblTemp TABLE(iId_company INT) INSERT INTO @tblTemp(iId_company) SELECT id FROM ..... The SELECT returns 138 results, but inserting in the TABLE variable takes 1min15 but when I use a temp table with the ...

Should you use temporary tables to pass data between stored procedures?

I have a number of search functions (stored procedures) which need to return results with exactly the same columns. This is the approach that was taken: Each stored procedure had the general structure: CREATE TABLE #searchTmp (CustomerID uniqueIdentifier) INSERT INTO #searchTmp SELECT C.CustomerID FROM /**** do actual search h...

How to pass a SQL temp table to a C# stored procedure

What's the best way to pass a temp table to a C# stored procedure (SQL 2008)? Am I stuck passing the temp table name as text and running a select from C#? I was hoping to use Table Value Parameters, but they don't appear to be supported in C# sprocs. ...

Can I CREATE TEMPORARY TABLE in SQLAlchemy without appending to Table._prefixes?

I'd like to create a temporary table in SQLAlchemy. I can build a CREATE TABLE statement with a TEMPORARY clause by calling table._prefixes.append('TEMPORARY') against a Table object, but that's less elegant than table.select().prefix_with() used to add a prefix to data manipulation language expressions. Is there an equivalent to .prefi...

Oracle 10g temp tables

I'm trying to convert the permanent tables used in a stored procedure to global temp tables. I've looked at the stats on these permanent tables and some have tens of millions of rows of data and are on the order if gigabytes in size (up to 10 GB). So, CREATE TABLE my_table ( column1 NUMBER, column2 NUMBER, etc... ) TABLESPAC...

How to create unique temporary tables in MySQL procedures?

I was creating a temporary table in my procedure, but I always got an error "table already exists". Then I tried to create a random name to avoid collision but I don't know enough about how to execute SQL strings SET @tbName = CONCAT('temp', random_id); PREPARE stmt1 FROM 'CREATE TEMPORARY TABLE ? (`FIELDNAME` float NOT NULL);'; EXECU...

oracle - Temp table vs. Permanent table

In Oracle, what is the difference between temp and permanent tables? ...

using a temporary table with NHibernate

I'm trying to make what seems to be an advanced use of NHibernate with sql server functions. I'm using NHibernate's ICriteria interface to supply paging, sorting and filtering for my listviews. one of business objects is an aggregation of items from 3 different tables. in order to do this aggregation in the DB I've used a transact-sql fu...

Is it possible to create a temp table on a linked server?

I'm doing some fairly complex queries against a remote linked server, and it would be useful to be able to store some information in temp tables and then perform joins against it - all with the remote data. Creating the temp tables locally and joining against them over the wire is prohibitively slow. Is it possible to force the temp tab...

Save Rails ActiveRecord objects into a temporary table (MySQL)

A user can import data into our website from a file. The data normally contains several hundred Items (Item < ActiveRecord::Base). Although the validations help, they cannot solve the problem of sanity-checking the content. For that we would like to have a test mode. Could we use a temporary Items table for this with Rails/MySQL, and,...

is a mysql temporary table unique for each user accessing the script that creates it...?

Hi everyone... While looking for a way to temporarily save the search results when a user searches for a hotel free between particular dates i came across temporary tables. But certain questions are not answered even in mysql manual.... like... Will the temporary table be unique for each user that executes the script...? Or will it b...

Hibernate design: persistent data plus temporary run-time classes

The question is this. I have a number of persisted objects that I'll pull using Hibernate. But during the application lifetime I'll create a few objects that do not live outside the running time of an app. They are temporary, for example contain user's choices, and they also hold links to the persistent objects(tables). But as soon as...

Using "AS" in MySQL - not as aliases

Hi, I was kinda surprised when I saw following: CREATE TEMPORARY TABLE X (ID int) AS SELECT NumColumn FROM Table I have tried to google it but only found using this as alieases. What this use actually is? I feel bit confused since I was stupidly creating temporary table and then fill it by using of insert.. Thank you ...

TSQL - How to join 1..* from multiple tables in one resultset?

A location table record has two address id's - mailing and business addressID that refer to an address table. Thus, the address table will contain up to two records for a given addressID. Given a location ID, I need an sproc to return all tbl_Location fields, and all tbl_Address fields in one resultset: LocationID INT, ...

Searching Week-wise/Month-wise record counts(number) and the StartDate+EndDate(datetime) of the Week/Month with Search between two Dates

I have a question in connection to this question earlier posted by me:- http://stackoverflow.com/questions/2452984/daily-weekly-monthly-record-count-search-via-storedprocedure I want to have the Count of Calls on Weekly-basis and Monthly-basis, Daily-basis issue is resolved. ISSUE NUMBER @1:Weekly-basis Count of Calls and Start-Date a...

DML statistics on a table

We're using PostgreSQL 8.2. In our application, we heavily use a temporary table (REPORTTEMP) for report generation purpose. All type of DML statements are performed in this table, but UPDATE statement is comparatively very low with INSERTs and DELETEs. So, at any point of time, after completion of the transaction, record count in th...

SQL Server: how to insert to temporary table?

I have one Temporary Table CREATE TABLE #TEMP (TEMP_ID INT IDENTITY(1,1)) And I would like to insert records to that table, How can I?I do as follow: INSERT INTO #TEMP DEFAULT VALUES But sometimes it doesn't work. What it might be?And I would like to know lifetime of temptable in SQL Server. Please Help me! Thanks all! ...

PHP, MySQL, and temporary tables

Php novice. 1.Is there anything wrong with this PHP & MySQL code? include_once "db_login.php" ; $sql = "DROP TEMPORARY TABLE IF EXISTS temp_sap_id_select" ; mysql_query ( $sql ) or ( "Error " . mysql_error () ) ; $sql = " CREATE TEMPORARY TABLE temp_sap_id_select ( `current_page` INT NOT NULL, ...

Micosoft SQL Server 2005 check if temporary table empty

Is there a fast/efficiency way to check if a table is empty? DECLARE @StartEndTimes TABLE ( id bigint, StartTime datetime, EndTime datetime ) IF @StartEndTimes IS NOT NULL ...