thendrickson
Programmer
This has probably been answered befor, but I have a create table statement failing.
I check for IF exists in sysobjects then drop the twtable and try to create a new table.
I receive the error that the table already exists.
This is the code I have always used
IF EXISTS
( SELECT *
FROM dbo.sysobjects
WHERE id = object_id( N'[tmpWhatever]' )
AND ObjectProperty( id, N'IsUserTable') = 1 )
DROP TABLE tmpWHatever
CREATE TABLE [tmpWhatever] ( ETC, ETC ETC
The create generates the error that the table already exists.
THe confusing part is that if I use this code to debug. The table is gone after the drop but the Create still fails,
IF EXISTS
( SELECT *
FROM dbo.sysobjects
WHERE id = object_id( N'[tmpWhatever]' )
AND ObjectProperty( id, N'IsUserTable') = 1 )
Begin
Print 'Dropping it'
DROP TABLE tmpWHatever
end
IF EXISTS
( SELECT *
FROM dbo.sysobjects
WHERE id = object_id( N'[tmpWhatever]' )
AND ObjectProperty( id, N'IsUserTable') = 1 )
else
Print 'tbl is gone'
So the table is not in sysobjects at this point, but my CREATE TABLE still fails even though it isthe very next code to fire.
Any ideas would be welcome
I check for IF exists in sysobjects then drop the twtable and try to create a new table.
I receive the error that the table already exists.
This is the code I have always used
IF EXISTS
( SELECT *
FROM dbo.sysobjects
WHERE id = object_id( N'[tmpWhatever]' )
AND ObjectProperty( id, N'IsUserTable') = 1 )
DROP TABLE tmpWHatever
CREATE TABLE [tmpWhatever] ( ETC, ETC ETC
The create generates the error that the table already exists.
THe confusing part is that if I use this code to debug. The table is gone after the drop but the Create still fails,
IF EXISTS
( SELECT *
FROM dbo.sysobjects
WHERE id = object_id( N'[tmpWhatever]' )
AND ObjectProperty( id, N'IsUserTable') = 1 )
Begin
Print 'Dropping it'
DROP TABLE tmpWHatever
end
IF EXISTS
( SELECT *
FROM dbo.sysobjects
WHERE id = object_id( N'[tmpWhatever]' )
AND ObjectProperty( id, N'IsUserTable') = 1 )
else
Print 'tbl is gone'
So the table is not in sysobjects at this point, but my CREATE TABLE still fails even though it isthe very next code to fire.
Any ideas would be welcome