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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Short answer…on IQ this isn’t possible. Long answer…you have a few fairly good choices and some not so good choices.
Rewrite the entire procedure in old watcom SQL, trap the error if the operation to drop the table fails…
Use a permanent table (no effective difference between the 2 in IQ as far as I know)
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 🙂
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: