Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

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



Report this thread to moderator Post Follow-up to this message
Old Post
serge
12-14-05 06:23 PM


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)

Report this thread to moderator Post Follow-up to this message
Old Post
Hugo Kornelis
12-15-05 01:25 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 11:21 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006