SQL Server创建/更新数据库脚本

时间:2022-03-27 12:48:16

In MS SQL Server 2005, how can I create a script consisting off all the objects in the database (tables, stored procedures, views)? I want to use the script to create the database using SMO or to update its objects (alter, drop) if they already exist. I know about the scripting feature in SQL Server Management Studio, I am however not familiar with the configuration options.

在MS SQL Server 2005中,如何创建一个包含数据库中所有对象(表,存储过程,视图)的脚本?我想使用脚本使用SMO创建数据库,或者更新其对象(alter,drop)(如果已存在)。我知道SQL Server Management Studio中的脚本功能,但我不熟悉配置选项。

3 个解决方案

#1


If versioning your database schema is what you're getting to, try Wizardby. Although it does not directly support neither views nor sprocs, it supports running native SQL scripts as part of an upgrade/downgrade process.

如果您正在对数据库模式进行版本控制,请尝试使用Wizardby。虽然它既不直接支持视图也不直接支持sprocs,但它支持在升级/降级过程中运行本机SQL脚本。

#2


I use Easy Sql Tools. The deploy version is free. You can generate scripts from schemas, data, indexes, almost everything.

我使用Easy Sql Tools。部署版本是免费的。您可以从模式,数据,索引,几乎所有内容生成脚本。

http://www.easysqltools.com

#3


There's a great tool SQL Compare that will actually compare two databases and create a change script for you. It's a great tool for staging purposes. There's also SQL Data Compare tool that will also compare lookup tables and act accordingly.

有一个很好的工具SQL Compare,它将实际比较两个数据库并为您创建一个更改脚本。它是一个很好的分期工具。还有SQL数据比较工具,它还将比较查找表并相应地采取行动。

The downside is, they're not free. :(

缺点是,他们不是免费的。 :(

#1


If versioning your database schema is what you're getting to, try Wizardby. Although it does not directly support neither views nor sprocs, it supports running native SQL scripts as part of an upgrade/downgrade process.

如果您正在对数据库模式进行版本控制,请尝试使用Wizardby。虽然它既不直接支持视图也不直接支持sprocs,但它支持在升级/降级过程中运行本机SQL脚本。

#2


I use Easy Sql Tools. The deploy version is free. You can generate scripts from schemas, data, indexes, almost everything.

我使用Easy Sql Tools。部署版本是免费的。您可以从模式,数据,索引,几乎所有内容生成脚本。

http://www.easysqltools.com

#3


There's a great tool SQL Compare that will actually compare two databases and create a change script for you. It's a great tool for staging purposes. There's also SQL Data Compare tool that will also compare lookup tables and act accordingly.

有一个很好的工具SQL Compare,它将实际比较两个数据库并为您创建一个更改脚本。它是一个很好的分期工具。还有SQL数据比较工具,它还将比较查找表并相应地采取行动。

The downside is, they're not free. :(

缺点是,他们不是免费的。 :(