Solved

creating tempdb from sybase

Posted on 2010-09-16
6
729 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:tlovie
ID: 33695938
Have you tried the syntax like this:

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

Expert Comment

by:alpmoon
ID: 33696035
What is the error message you receive?
0
 

Author Comment

by:4Learning
ID: 33696078

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
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 
LVL 7

Accepted Solution

by:
tlovie earned 250 total points
ID: 33696141
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
ID: 33696228
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
ID: 33851583
Solution available
0

Featured Post

ClickHouse in a General Analytical Workload

We have mentioned ClickHouse in some recent posts, where it showed excellent results.

In this article on Experts Exchange, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
First of all let me say that the only language that I speak is English, but in answering questions here I often come across people whose English skills are not the best and I’d like to be able to communicate better with them, and the following descr…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

632 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