How to drop a table with weird name

Post Reply
barry.marcus
Posts: 288
Joined: Thu Nov 16, 2006 1:05 pm

How to drop a table with weird name

Post by barry.marcus »

I inadvertently created a table in my DB, and assigned the name '.' to it!!! That is, the name of the table is the single period character. (Ridiculous, I know...! It happened because I accidentally used a dot in the wrong place in the cpdb command. Oops!) Anyway, I suppose it's not doing any harm just being there, but I'd like to get rid of it. I can't figure out how to drop it, though. The command "DROP TABLE ." is syntactically incorrect. Any ideas?

Thanks
User avatar
John
Site Admin
Posts: 2597
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

How to drop a table with weird name

Post by John »

Double quote the name, e.g.

tsql
SQL 1> drop table ".";
John Turnbull
Thunderstone Software
User avatar
mark
Site Admin
Posts: 5513
Joined: Tue Apr 25, 2000 6:56 pm

How to drop a table with weird name

Post by mark »

If that doesn't work you can rename the table then drop it and cleanup the mess.

tsql -u _SYSTEM "update SYSTABLES set NAME='zzz' where NAME='.'"
tsql "drop table zzz"
tsql -u _SYSTEM "delete from SYSCOLUMNS where TBNAME='.'"
tsql -u _SYSTEM "delete from SYSPERMS where P_NAME='.'"
tsql -u _SYSTEM "delete from SYSSTATISTICS where Object='.'"
barry.marcus
Posts: 288
Joined: Thu Nov 16, 2006 1:05 pm

How to drop a table with weird name

Post by barry.marcus »

Thanks! All cleaned up!
Post Reply