Go Back   Rhinocerus > Newsgroup > Newsgroup comp.databases.* > Newsgroup comp.databases.ms-sqlserver

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 12-14-2005, 05:04 PM
serge
Guest
 
Posts: n/a
Default Temp tables vs table variables

I am running SQL Server Best Practices on a SQL 2000
database and it is recommending me to change the temp
tables inside SPs to table variables.

I had read already in other places to use table variables
over temp tables. I also know I can't create indexes as
I can on temp tables. Instead I'll have to create either
a primary key and/or a unique index on a table variable.

One question I have is let's say I will be putting thousands
of records in a temp table, should i still choose a table
variable over a temp table for this? Or is there a
recommended limit where if I have to store certain
number of records then it's better to store them in
a temp table rather than a table variable? Or number
of records is not the factor to decide whether to use
temp tables or table variables?

I would like to know when it's ideal or best to use
temp tables instead of table variables and vice versa.

Thank you


Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 12-14-2005, 11:04 PM
Hugo Kornelis
Guest
 
Posts: n/a
Default Re: Temp tables vs table variables

On Wed, 14 Dec 2005 13:04:05 -0500, serge wrote:

>I am running SQL Server Best Practices on a SQL 2000
>database and it is recommending me to change the temp
>tables inside SPs to table variables.
>
>I had read already in other places to use table variables
>over temp tables. I also know I can't create indexes as
>I can on temp tables. Instead I'll have to create either
>a primary key and/or a unique index on a table variable.
>
>One question I have is let's say I will be putting thousands
>of records in a temp table, should i still choose a table
>variable over a temp table for this? Or is there a
>recommended limit where if I have to store certain
>number of records then it's better to store them in
>a temp table rather than a table variable? Or number
>of records is not the factor to decide whether to use
>temp tables or table variables?
>
>I would like to know when it's ideal or best to use
>temp tables instead of table variables and vice versa.
>
>Thank you
>


Hi Serge,

There is no hard and fast rule. Testing is the only way to find out for
sure which solution will be best in your situation.

As a rule of thumb, therre tends to be some bias towards table variables
for small amounts of data and towards temp tables for large amounts of
data.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Create new tables from old tables Howard Schreier Newsgroup comp.soft-sys.sas 0 01-18-2009 05:12 PM
Re: Create new tables from old tables Gerhard Hellriegel Newsgroup comp.soft-sys.sas 0 01-14-2009 02:14 PM
Re: PROC FREQ--DATA STEP--MODELING QUESTION Gerstle, John Newsgroup comp.soft-sys.sas 0 06-06-2007 07:47 PM
Re: One dimentional table for a dozen variables toby dunn Newsgroup comp.soft-sys.sas 0 09-07-2006 02:06 PM
Re: One dimentional table for a dozen variables Nat Wooding Newsgroup comp.soft-sys.sas 0 09-07-2006 01:58 PM



All times are GMT. The time now is 02:34 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.