December 3, 2007 at 2:25 pm
Hello
When i try to recreate a database i get the following error messgae:
There is already an object named 'Office' in the database.
What can i do?
December 3, 2007 at 2:49 pm
Presumably you are recreating the database + objects from scripts. Check your scripts for the duplicate object (probably a table, so look for CREATE TABLE statements). See if they are the same structure/code. If so, remove the duplicate. If not, find who provided the scripts & get them to explain/fix.
MARCUS. Why dost thou laugh? It fits not with this hour.
TITUS. Why, I have not another tear to shed;
--Titus Andronicus, William Shakespeare
December 3, 2007 at 4:26 pm
Am using the go statement after each create table statement do you think that is the problem.
December 3, 2007 at 6:16 pm
Nope. Nothing wrong with that. Like I wrote above, check for a duplicate CREATE statement - it's likely that two of them will have the same name 'Office'. E.g. CREATE TABLE Office or CREATE PROCEDURE Office et al.
MARCUS. Why dost thou laugh? It fits not with this hour.
TITUS. Why, I have not another tear to shed;
--Titus Andronicus, William Shakespeare
December 6, 2007 at 10:21 am
Check for the existence of the table for creating it
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[TABLENAME]') AND type in (N'U'))
BEGIN
CREATE TABLE TABLENAME
(
COL1 INT,
COL2 VARCHAR(10)
)
END
GO
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply