Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / July 2003



Tip: Looking for answers? Try searching our database.

Temporary Tables in SQL Server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sue - 30 Jul 2003 04:09 GMT
Hello

I'm new to SQL Server, hence this trivial question. I have an
application in VB 6.0, database- SQL Server 7.0 and I use ADO for
connectivity.

For reporting purpose, I create a global temp table (##) from the vb
application. I know that the table is created, because I try to insert
some value and try to read the value and its there. My question is

1. When I open the Enterprise manager and look in the TempDb section
to look at the tables, I do not see the table I had created. I know
that once you disconnect the table gets deleted, hence, I make sure I
put a breakpoint once I insert all the records. Where do I look to see
the table that got created.

Here is the code (on the air) I had written and it runs fine without
errors.

db.execute "Create table ##Ap_Tmp (cons_code char(6), cust_code
char(6))"

db is my database connection. Because I prefix it with "db" does the
temp table get created in my database?? I'm confused !!

2. Also, could someone give me an example as to how I check to see if
the temporary table that I created exists ??

TIA
Sue..
Tore Bostrup - 30 Jul 2003 06:26 GMT
I don't have SQL Server 7.0 loaded here, but in SQL Server 2000 Query
Analyzer, you can see the global temp tables in the Object Browser under
tempdb User Tables.

Tools > Object Browser > Show/Hide

HTH,
Tore.

> Hello
>
[quoted text clipped - 26 lines]
> TIA
> Sue..
Val Mazur - 30 Jul 2003 11:32 GMT
Hi Sue,

All the temporary tables are listed in tempdb database. You should check
there. I think you could check it same way as you check if regular table
exists - try to execute next kind of statement

SELECT * FROM SYSOBJECT WHERE [NAME]="##Ap_Tmp" AND TYPE ="T"

--
Val Mazur
Microsoft MVP

> Hello
>
[quoted text clipped - 26 lines]
> TIA
> Sue..
Sue - 30 Jul 2003 17:06 GMT
Hello Val

Thanks for your response. But, I have some more questions.

I did check in the tempdb section, under tables and could not see the
temp table "Ap_tmp" that I had created. I know for sure that it got
created as I'm able to access records from there, but can't see it.

The statement you had provided to check if the temp table exists:

SELECT * FROM SYSOBJECT WHERE [NAME]="##Ap_Tmp" AND TYPE ="T"

How do i use it, in the sense, do I create a like a recordset and try
to open this recordset and check for eof and bof or, is there an other
way to do it. Would appreciate if you can give me an example.

Thanks
Sue..

> Hi Sue,
>
[quoted text clipped - 38 lines]
> > TIA
> > Sue..
Val Mazur - 30 Jul 2003 23:29 GMT
Hi Sue,

Yes, you execute that SQL statement and it should return you recordset. In
number of records is greater than 0 then you have that table. If you just
check list of available table from inside Enterprise Manager, you may not
see it.

--
Val Mazur
Microsoft MVP

> Hello Val
>
[quoted text clipped - 57 lines]
> > > TIA
> > > Sue..
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.