1

Topic: The temporary table with a name demanding [] - how to learn presence?

It is given:

 Microsoft SQL Server 2005 - 9.00.5069.00 (X64)
Aug 22 2012 6:02:46 PM
Copyright (c) 1988-2005 MICROSOFTS CORPORATION
Enterprise Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) 
use mydb
go
create table [#t-1-2-3] (n int)

We check:

use tempdb
go
select name from sys.objects where type ='U ' and name like ' % - %'
 name
--------------------------------------------------------------------------------------------------------------------------------
#t-1-2-3____________________________________________________________________________________________________________0000000BEF98
(1 row (s) affected) 

- Everything is all right, the table is created. If in a table name there were no the characters demanding  a manor, I would define the fact of existence of the temporary table so:

select object_id (' tempdb..#mytable ')

However in this case

select object_id (' tempdb..#t-1-2-3 ')

Returns NULL. And

select object_id (' tempdb. [#t-1-2-3] ')

Too returns NULL. How to check up the fact of existence of the table in the described case?

2

Re: The temporary table with a name demanding [] - how to learn presence?

quoted table;
That like all it is normal

create table [#t-1-2-3] (n int)
SELECT OBJECT_ID (' tempdb..#t-1-2-3 ')
-- -1599351997

3

Re: The temporary table with a name demanding [] - how to learn presence?

TaPaK wrote:

quoted table;
That like all it is normal

, indeed. It is strange, why at first it did not work for me. Thanks.