使用Visual Studio 2010数据库项目删除表 [英] Dropping a table with Visual Studio 2010 Database Project

查看:416
本文介绍了使用Visual Studio 2010数据库项目删除表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Visual Studio 2010中的数据库项目,我想知道如何让差异脚本生成器包括一个DROP TABLE语句。如果我在Tables文件夹中创建一个新的表脚本,差异选择并在部署脚本中包含一个CREATE TABLE语句,但是当我从项目中删除该SQL文件时,它不会在脚本中放置一个DROP。

I'm just starting to work with database projects in Visual Studio 2010, and I'm wondering how I get the differential script generator to include a DROP TABLE statement. If I create a new table script in the Tables folder, the differential picks that up and includes a CREATE TABLE statement in the deployment script, but when I delete that SQL file from the project, it doesn't put a DROP in the script.

我已验证这同样适用于存储过程。有没有办法摆脱数据库中的现有对象?

I've verified that this applies to stored procedures as well. Is there any way to get rid of existing objects in the database?

注意:我认为这将适用于Visual Studio 2008 Team System for Database Developers(Data Dude)GDR。

Note: I think this would apply to Visual Studio 2008 Team System for Database Developers (Data Dude) GDR as well.

推荐答案

(这些说明适用于VS 2008 GDR2,但我相信你说,如果VS 2010不一样,这些将是类似的。)

(These instructions apply to VS 2008 GDR2, but I believe as you said, these will be similar if not identical for VS 2010.)

您可以打开项目设置并转到部署选项卡,并选中标记为为目标数据库中但不在数据库项目中的对象生成DROP语句的框。

You can open the project settings and go to the Deploy tab and check the box labeled "Generate DROP statements for objects that are in the target database but that are not in the database project".

根据工作方式,您可能还需要取消选中标记为如果数据可能丢失,阻止增量部署的框。公平的警告,虽然,这是一个有风险的事情,你可能希望在部署之前自动备份数据库,而你在那里。

Depending on how you work, you may also need to uncheck the box labeled "Block incremental deployment if data loss might occur". Fair warning, though, that this is a risky thing to do, and you might want to have it back up the database automatically before deployment while you're in there.

这篇关于使用Visual Studio 2010数据库项目删除表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆