Questions tagged [temp-tables]

Temporary tables are a feature of RDBMS's as a means of storing intermediate results. Some RDBMS's make the distinction between local and global temporary tables. Temporary tables are typically dropped when the session ends for local, or when the temporary table is no longer referenced for global. Note that a temporary table is not the same as a table variable even though both are temporary in nature.

The term temporary table is somewhat misleading, because the tables are permanent, just the data is somewhat volatile.

Temporary tables are useful to store intermediate data. Since it only exists for a session or a transaction the RDBMS doesn't have to worry about locks in order to synchronize between different transactions or redo information. This makes temporary tables often faster and more efficient then normal tables.

1496 questions
-1
votes
1 answer

Create global temporary table from result of sql code with multi joins in SAS(TSQL Code)

I have a scenario where I have several sql server data source tables. I have read only access to these sources. I cannot create permanent tables in Sql Server environment. I can however create temporary tables. I thought of creating global temporary…
-1
votes
1 answer

SQL View slow when filtered. Is there a clean way to improve performance?

Let me open with: SHOWPLAN permission denied in database 'MyDatabase'. With that out of the way, I'll layout my situation. So, The database I work with has a view that executes fairly quickly. SELECT * FROM MyView returns 32 rows in 1 second…
LanchPad
  • 207
  • 3
  • 7
-1
votes
1 answer

Sending the stored procedure output as comma-separated rather than multiple rows

I have a stored procedure that returns multiple rows with 5 columns: SELECT Travel, ID, Dept, Role, Country FROM TravelManager For example, I get: DName ID Dept Role Country ---------------------------------- Travel 23 HR H …
Jasmine
  • 4,876
  • 13
  • 48
  • 100
-1
votes
1 answer

PreparedStatement.execute() returns false even there is resultset in SQL server?

My sql query consists of 5 part which are highly connected to each other. First part creates a temporary table, second part uses that temporary table and creates another temporary table, third part uses the temporary table that created in second…
JollyRoger
  • 505
  • 8
  • 24
-1
votes
3 answers

SQL Cursor to check number of string concate it and store it in temporary table

I am having one table containing 3 Columns FirstName, LastName, Salary So what i have to do is that i need to make one temporary variable table then i need to perform the operation on Column FirstName as checking the Length of each field of…
-1
votes
2 answers

Need suggestion on temporary data storage of CSV data for validation purposes

We have a requirement wherein user can upload bulk amount of data through CSV file, this may contain 20-30k records. Now we need to validate each record before inserting it into oracle DB. We also have a mongoDB used for some other business logics.…
-1
votes
2 answers

calculate financial periods into temp table

I have a client who reports on 13 27 day periods in the financial year and I am trying to work out some dynamic SQL to identify what reporting period an invoice was raised in. This is what I have so far but the while loop is crashing after the first…
-1
votes
2 answers

Creating temp table in Vertica

want to create a temp table in vertica containing lat, lng and restaurant_name I am writing the code as below but it throws an error: CREATE LOCAL TEMP TABLE geo_raw ( lat float, lng float, resto_name varchar) on commit PRESERVE rows INSERT INTO…
-1
votes
1 answer

How tables prefixed with TempDB work? Preventing running out of memory with many temp tables

In this article I found statement: Temporary tables come in different flavours including, amongst others, local temporary tables (starting with #), global temporary tables (starting with ##), persistent temporary tables (prefixed by TempDB..), and…
Yoda
  • 15,011
  • 59
  • 173
  • 291
-1
votes
1 answer

What is that makes temp tables more efficient than table variables when working with large data?

In SQL Server, the performance of temp tables is much better (in the means of time) compared to table variables when working with large data (say inserting or updating 100000 rows) (reference: SQL Server Temp Table vs Table Variable Performance…
user1080381
  • 1,252
  • 1
  • 13
  • 20
-1
votes
1 answer

How to create a temporary table or CTE with values from two sources

Need to build a temporary table or a CTE for reporting purposes. Users will be able to select a location and courses from drop-downs. The tables involved are the Person table that holds all employees and a Common Table Expression that will have the…
-1
votes
1 answer

sql left converts char to int?

I'm trying to compare a table and a report table as a proof of test, with the report table containing a 12 character ID plus their DOB, and the source table only having an ID. select cast(ID as char(12)) as ID into #IDnums from members where…
lefeal
  • 53
  • 5
-1
votes
1 answer

What is the difference between views and temporary tables in mysql? which is better?

What is the difference between views and temporary tables in mysql? which is better?
-1
votes
1 answer

Using "exec" to Update a Table

I have a temp table named as #temp with 2 columns: clientID (varchar), result (int) I just want to loop in it and check the clientID with a stored procedure which takes 2 varchar parameters and returns 0 or 1. I coded: update #temp set…
-1
votes
1 answer

How To Get Temp Table to Run Multiple Time

I'm using MS SQL Server. I'm currently working on a query for pulling headcount. In this process, I'm creating temp tables, but noticed that I can only run the query once. If I try running it again after making changes, it gives me the 'There is…
Mark L
  • 1
  • 1