8

I deleted a table in SQL Server Management Studio. And then I created a new table with the same name. But the error said that the table has already exists. I want a new completely table with the same name.

1
  • post ur DDLs. whatever you have executed...
    – Teja
    Mar 20, 2012 at 18:01

3 Answers 3

10

Edit: Added more answers after comment.

Are you removing the table from the database diagram or from the object explorer? If you are removing the table from your database diagram using Visual Database tools, it will still exist in the database. From MSDN:

The table is removed from your diagram but it continues to exist in the database.

OR,

Try going to Tools->Options->Designers and unchecking the box that says "Prevent saving changes that require table re-creation". Then try deleting and creating the database.

OR,

Delete the table. Close MS SQL Management Studio. Open MS SQL Management Studio again. Create table.


Old Answer

Are both statements in the same batch? From the Microsoft support page for DROP TABLE:

DROP TABLE and CREATE TABLE should not be executed on the same table in the same batch. Otherwise an unexpected error may occur.

If this isn't the case I'll try to help otherwise. If I can't help otherwise I'll just delete this answer.

3
  • I didn't write any statement. I deleted and created tables using ms sql server management studio. I mean "I deleted a table. It disappeared in server explorer. But it still exists. I want to completely remove it. plz help me again."
    – Jenny
    Mar 20, 2012 at 19:04
  • Edited my answer. If you go into Object Explorer, right click the table, and press Delete, it should delete it completely unless you don't have permissions or you need to do one of the things in my edited answer. Can you check it out and let me know how you make out?
    – rownage
    Mar 20, 2012 at 19:39
  • Ohh,Thanks. I could make it out. The source of the problem is I have to uncheck "Preventing saving changes that require table re-creation".
    – Jenny
    Mar 20, 2012 at 23:31
5

Basically you have one of it open in tab where you get new table...

Steps

  • Close all the tabs
  • When no tabs are open
  • Create you table

And there you are.... It worked for me rather than creating the whole database again.

0
0

Clock on Tools -> Options -> Designers -> UNcheck Prevent table changes from table re-creation check box.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.