December 19, 2005 at 9:32 am
Hello all,
I need some help. I'm writing a data import SQL procedure. I've been trying to use the "populate a temp table, rename the original, rename the temp table to the real name, drop the original table you just renamed" method.
But this keeps failing, after running the block of statements like these below more than once, the original table's name is not really free so the second table cannot be renamed and trying to drop the original again fails because it's supposedly not in the system catalog but it's name is in fact still in the system table. You can see that both table names end up in sysobjects.
thanks in advance for any suggestions you have!
-- WHAT'S UP WITH THIS TABLE NAME STICKING????
CREATE TABLE dbo.dropME(ID int)
CREATE TABLE dbo.RenameME(ID int)
DROP TABLE dbo.dropME
EXEC SP_RENAME 'dbo.RenameME', 'dbo.dropME'
SELECT * FROM sysobjects WHERE NAME LIKE '%ME'
Skål - jh
December 19, 2005 at 10:01 am
In the example you give, you are renaming the table to 'dbo.dropME', where 'DBO.' is part of the actual table name, not an owner prefix.
Try EXEC SP_RENAME 'RenameME', 'dropME'
December 19, 2005 at 10:02 am
Need to have "go" between the statements. A create table needs its own batch
December 19, 2005 at 10:39 am
OK, thanks gang! That helped a lot.
Skål - jh
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply