I am working on a database design using the SQL Server Database Diagram tool. I created a table with the name dbo.Example and before defining any columns, attempted to save.
Got an error that SQL can't save a table without any columns and as I wanted to save the other work I had done before completing this table, I deleted it and saved successfully.
I then make many more changes and save the diagram. All is good.
UNTIL I am ready to correctly define my dbo.Example table and get the
'Table 'dbo.Example' already exists' error.
The table is not among the tables returned from
select name from sys.tables;
and does not appear in the Database->Tables GUI view.
I can't find where I need to clean up and drop this table.
Where does SQL Server keep the metadata about the database diagrams?
Best Answer
This is a bug in Management Studio.
I was able to reproduce it three ways, on both 2008 R2 and 2012 tools:
From this behaviour, I'm guessing it keeps a list of tables per database outside the context of a single database diagram, and when an empty table is deleted, the reference isn't being cleaned up properly. I believe the fix is to close all diagrams for that database, and re-open. I think it's lucky you were able to save the changes you made with no errors!
I would suggest reporting this on Connect if you feel it's really important. IMO, it seems unlikely it will be fixed because it's so minor, but you never know.