Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 2nd, 2004, 10:00 AM
Hoyas Hoyas is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 1 Hoyas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Temporary tables in SQL Server and ASP

Hi, guys:
I need to use temporary tables from my ASP application.

I insert records into temporary table #q1
do
Set objRecordset1 = objConnection.Execute(SQLs)


then i try to do
SQLs= "Select * from #q1"
Set objRecordset1 = objConnection.Execute(SQLs)

but at this point i get an error message

[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name '#q1'.

I realize that this temporary table is expired already. How can I keep it alive so that i could use it with my other queries, and then have it destroyed at the end of the session?

Thanks a lot, i really need ur help

Nath

Reply With Quote
  #2  
Old March 25th, 2004, 08:37 AM
bindu_h bindu_h is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 1 bindu_h User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up temp tables

what i suggest is when you create temp table and drop them it has to be all in one tread / connection. I have an example here to create / insert and drop the temp table :

set objConn = Server.CreateObject("ADODB.Connection")
set objConn = Session("myDBConnection")

SqlStr = "create table #t_temp ("
& "ManifestID numeric(9,0), "_
& "CreateDate datetime)"
objConn.Execute SqlStr

SqlStr = "Insert into #t_temp (ManifestID , CreateDate) "_
& "Values (10, '10/25/2004')"
objConn.Execute SqlStr

Set objRS = Server.CreateObject("ADODB.RecordSet")
StrSql = "SELECT * FROM #t_temp order by ManifestID"
objRS.Open StrSql, objConn, 3, 1

objConn = Nothing

Hope this will solve the problem.

Reply With Quote
  #3  
Old May 19th, 2005, 01:26 PM
John Wardale John Wardale is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 1 John Wardale User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 14 sec
Reputation Power: 0
Definition of "Session" for a temporary table

I'm trying to share a temporary table between 2 Stored Procedures. The outer procedure creates the table, but the inner procedure [Execute sp_Inner ....] can't access the table.

2nd case:
From ASP code, I call a Stored Procedure that generates a temporary table, but again, the following ASP code can't access the table.

The 1st case I have a work-around [perminant tables]

For the 2nd case, I'd like to have different tables if/when different users access this page so the "perminant table" work-around is a readers/writers conflict waiting to happen.

In the 2nd case, the S.Proc and the SQL to access the table are done thru the same ADO.Session object.

Should this work, or am I doing something wrong, and if so, does anyone know how to make this work?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Temporary tables in SQL Server and ASP


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 5 hosted by Hostway