Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8914853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:49:54+00:00 2026-06-15T04:49:54+00:00

I have created a table as below: create table #tab ( id int )

  • 0

I have created a table as below:

create table #tab
(
  id int
)

Now, I want to get an object id of the table.

I tried on the same session:

select object_id( "#tab" ) 

and

select object_id( "tempdb..#tab" )

but both return null.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:49:55+00:00Added an answer on June 15, 2026 at 4:49 am

    Short answer…on IQ this isn’t possible. Long answer…you have a few fairly good choices and some not so good choices.

    1. Rewrite the entire procedure in old watcom SQL, trap the error if the operation to drop the table fails…

    2. Use a permanent table (no effective difference between the 2 in IQ as far as I know)

    3. Get funky…and use odd IQ behavior! If you create a temp table outside a transaction, then check @@trancount…you will get 0 as you expect. If you then open a transaction…and check @@trancount you will get 2. So…consider that a successful temp table creation 🙂

    4. Just assume it doesn’t exist on your connection 🙂

    Sybase ASA SQL Code list:
    http://manuals.sybase.com/onlinebooks/group-sas/awg0800e/dberen8/@Generic__BookTextView/334;pt=334#X

    Example for #1:

    DROP PROCEDURE foo;
    go
    create procedure foo()
    begin
      DECLARE DROP_TABLE_FAILED EXCEPTION FOR SQLSTATE '42W33';
    
      BEGIN
        DROP TABLE T1;
        EXCEPTION 
          WHEN DROP_TABLE_FAILED 
          THEN 
          WHEN OTHERS THEN RESIGNAL;
    
      END;
    
        CREATE LOCAL TEMPORARY TABLE t1 (c1 int) 
        on commit preserve rows;
    
        insert into t1 select 1;
    
        select * from t1;
    
    END;
    go
    exec foo
    go
    exec foo
    go
    drop table t1;
    go
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created one table using the below command: create table Table1( Id int
I have created table and inserted values as below. create table mytable (id INT,
e.g. If I have a table like below:- create table Categories(CategoryId int primary key,
I have an SQL table defined as below: CREATE TABLE [TestComposite] ( ID int,
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
Below is how my table is create table tab (id INT, fullname varchar(100)); Data
I have created a table using below mensioned query in MySQL. CREATE TABLE Pat_Visit
I have a table like below CREATE TABLE Customers_History(Row_Id INT NOT NULL PRIMARY KEY
I have a table like the one below. CREATE TABLE People(PeopleId INT NOT NULL
I have created a table create table #temp(a int, b int, c int) I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.