Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 3rd, 2005, 12:38 PM
kcconnor's Avatar
kcconnor kcconnor is offline
Evil Republican...
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Probably running over your cat right now...
Posts: 250 kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 21 h 35 m 23 sec
Reputation Power: 37
Temporary Tables

Does anybody know how long by default temporary tables last? How do you adjust temporary table lifetime? Is it possible to increase their lifespan?

Reply With Quote
  #2  
Old August 3rd, 2005, 12:55 PM
yogaboy yogaboy is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Location: Near London
Posts: 112 yogaboy User rank is Corporal (100 - 500 Reputation Level)yogaboy User rank is Corporal (100 - 500 Reputation Level)yogaboy User rank is Corporal (100 - 500 Reputation Level)yogaboy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 14 h 37 m 29 sec
Reputation Power: 5
Quote:
Originally Posted by kcconnor
Does anybody know how long by default temporary tables last? How do you adjust temporary table lifetime? Is it possible to increase their lifespan?


the book next to me says that local and global temporary tables stored in the tempdb last for as long as the connection that created/calls them. They are then dropped by SQL Server unless you explicitly drop them.

If you want to keep a temp table for longer it would be better to stick it in a table variable IMO (or create a "temporary" table explicitly in the database.)

Reply With Quote
  #3  
Old August 3rd, 2005, 02:52 PM
kcconnor's Avatar
kcconnor kcconnor is offline
Evil Republican...
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Probably running over your cat right now...
Posts: 250 kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 21 h 35 m 23 sec
Reputation Power: 37
So I have no control over this if I am using a third-party app that utilizes an ODBC connector for its SQL queries and cannot edit the source code? I can't extend the lifetime of a spid as it sits idle? There's no master idle connection timeout that I can extend?

Reply With Quote
  #4  
Old August 3rd, 2005, 04:34 PM
yogaboy yogaboy is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Location: Near London
Posts: 112 yogaboy User rank is Corporal (100 - 500 Reputation Level)yogaboy User rank is Corporal (100 - 500 Reputation Level)yogaboy User rank is Corporal (100 - 500 Reputation Level)yogaboy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 14 h 37 m 29 sec
Reputation Power: 5
the only way I know to extend the connection timeout is in the source code for the app. But I think that will be different from the spid as you can start several processes running in one connection.

You can get ODBC statistics, and they might tell you how long the processes are really lasting?

Reply With Quote
  #5  
Old August 3rd, 2005, 06:52 PM
kcconnor's Avatar
kcconnor kcconnor is offline
Evil Republican...
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Probably running over your cat right now...
Posts: 250 kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 21 h 35 m 23 sec
Reputation Power: 37
The processes don't really last all that long. What happens is the user runs one batch that generates a temporary table and a "view" (not a sql view) of the data they are manipulating. They then let the application sit idle. They push paper around on their desk, go get a cup of coffee, whatever. When they return and continue to work with the data on screen, the temporary table has expired and they get a runtime error saying "select * from #temptable" is referencing an invalid database object.

Reply With Quote
  #6  
Old August 4th, 2005, 05:46 AM
yogaboy yogaboy is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Location: Near London
Posts: 112 yogaboy User rank is Corporal (100 - 500 Reputation Level)yogaboy User rank is Corporal (100 - 500 Reputation Level)yogaboy User rank is Corporal (100 - 500 Reputation Level)yogaboy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 14 h 37 m 29 sec
Reputation Power: 5
I've been studying .NET lately, and this sounds like the perfect situation to use a dataset. It holds all the tables on the local client and only connects when prompted, like to make updates etc. I suppose that depends on the app you're using and whether the developers will sort that.

Either that, or you could output the data to an XML file and hold it locally on the client or on the network, depending on how often the data is updated.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Temporary Tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT