Solved

creating tempdb from sybase

Posted on 2010-09-16
6
672 Views
Last Modified: 2012-05-10
Hi,

I am unable to create a temporary table in the tempdb database from within a stored proc in a test database. However when I go directly to the tempdb database I am able to create temp tables. Can anyone tell me what is going wrong...

Eg:

Use my_test_db
create proc procname
as
   ----- procedure code
   create table tempdb..mytemptable1 ( col1 int null)
go
<<<<Result: Stored Proc not created>>>>


When I switch to tempdb and give the following command
create table tempdb..mytemptable1 (col1 int null)

... the table is successfully created in tempdb database.


Please help...
Thanks!

0
Comment
Question by:4Learning
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:tlovie
Comment Utility
Have you tried the syntax like this:

create table #mytemptable1 ( col1 int null)
0
 
LVL 13

Expert Comment

by:alpmoon
Comment Utility
What is the error message you receive?
0
 

Author Comment

by:4Learning
Comment Utility

Yes, I did try and #mytemptable1( col1 int null) works fine. The reason I am trying to use tempdb instead of # is because I want to see the values in those tables during my development phase.... even after the stored proc has finished execution.

I am not getting any error messages. As I mentioned earlier, I am able to create tempdb tables when I directly log into tempdb, but cannot create those same tables from within a stored procedure with a create table command.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 7

Accepted Solution

by:
tlovie earned 250 total points
Comment Utility
See, create table is going to fail if the table already exists...  What I generally do if I want to see what's inside of a temp table while developing is put a select statement at the end of the proc.

Or you can also create a permanent table either on your database or on tempdb, and use it, but in your proc, comment out the create table part.
0
 

Assisted Solution

by:4Learning
4Learning earned 0 total points
Comment Utility
Thanks tlovie.....

I figured out the problem....... and a silly one at that :-(

The procedure was running fine, and I was checking after creating my procedures to see if the temp tables were being created... THAT was a mistake.

The tables were created after I executed my stored procedure...

Thanks to you both for your time and knowledge....

Regards,
4learning
0
 

Author Comment

by:4Learning
Comment Utility
Solution available
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now