|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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? |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Temporary tables in SQL Server and ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|