Page 1 of 1

How to drop a table with weird name

Posted: Tue Jan 26, 2010 1:36 pm
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

How to drop a table with weird name

Posted: Tue Jan 26, 2010 1:51 pm
by John
Double quote the name, e.g.

tsql
SQL 1> drop table ".";

How to drop a table with weird name

Posted: Tue Jan 26, 2010 1:59 pm
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='.'"

How to drop a table with weird name

Posted: Tue Jan 26, 2010 2:16 pm
by barry.marcus
Thanks! All cleaned up!