Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How many records can insert into a temp table? Expand / Collapse
Author
Message
Posted Tuesday, March 25, 2014 6:00 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 7:40 AM
Points: 312, Visits: 589
I use code below to insert data into a temp table.
How many records can insert into a temp table?

Select * into #temp from ORDER
Post #1554401
Posted Tuesday, March 25, 2014 6:14 AM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 8:06 AM
Points: 4,229, Visits: 3,662
I don't know of a limit to the number of rows, so I guess it would depend on your available server memory. One thing you should do is watch your use of reserved words as object names. In your query, you should quote your table name like this:

Select * into #temp from [ORDER];

I don't think it'll work without the name quoted because it's a reserved word.



Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Post #1554411
Posted Tuesday, March 25, 2014 12:32 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 5:38 AM
Points: 13,876, Visits: 28,274
Rows will be limited by storage and that's storage in tempdb. Here's a listing of all the limits on SQL Server. Books Online is always one of the single best resources.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server Query Performance Tuning
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1554640
Posted Wednesday, March 26, 2014 2:27 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 7:41 AM
Points: 40,187, Visits: 36,593
The maximum size of TempDB, like all other databases, is ~525 000 TB, so that's the limit to how many rows you can put into a Temp Table. Probably a bit less, there's other stuff in TempDB as well.

Not limited by available memory because neither TempDB nor temp tables (nor table variables for that matter) are memory-only.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1554818
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse