开发者

Best way to remove all tables from a sql 2005 database

开发者 https://www.devze.com 2023-01-25 16:02 出处:网络
I have been developing an asp.net mvc site on a local version of sql server express 2008 and about a month ago I set up the web host and got everything working, the host uses sql server 2005. The site

I have been developing an asp.net mvc site on a local version of sql server express 2008 and about a month ago I set up the web host and got everything working, the host uses sql server 2005. The site is not live.

Now a month down the track I need to do a fairly big update and the database is way out of date.

I would like to know how I can retain the database but blow everything else away (tables etc.) so I can run the set up script again.

When I try a few things I find on the internet it complains about the foreign keys and doesn't delete.

T开发者_StackOverflowhanks in advance


if you truly don't need to retain anything (including users, roles, UDTs, etc), then just drop the db and create a new one.


Take a look at this answer to a question about disabling FK constraints, and rejoice! :)


my guess: it's all about the order you drop the tables

ex

table1 key fKeyTable2 (foreignkey from table 2)

table2 key

first drop table 2, then drop table1

if its hard to figure out the order you can try this: ALTER TABLE tbl_name DROP FOREIGN KEY fk_symbol; (fk_symbol = the foreign key that is being complained about)

0

精彩评论

暂无评论...
验证码 换一张
取 消