有“穷人"吗? RedGate的替代方案,用于编写整个数据库架构的脚本? [英] Is there a "poor man's" alternative to RedGate for scripting out entire database schema?

查看:132
本文介绍了有“穷人"吗? RedGate的替代方案,用于编写整个数据库架构的脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我处于一种情况,我将为可以在另一台服务器上运行的数据库生成脚本,并获得与原始服务器相同的数据库,但是没有任何数据.本质上,我想以一个捕获数据库模式的大型创建脚本结束.

I'm in a situation where I would to generate a script for a database that I could run on another server and get a database identical to the original one, but without any of the data. In essence, I want to end up with a big create script that captures the database schema.

我正在安装SQL Server 2000的环境中工作,并且无法安装2005客户端工具(如果它们会提供帮助).我负担不起RedGate,但我真的很想在另一台服务器上拥有一个具有相同架构的数据库.

I am working in an environment that has SQL Server 2000 installed, and I am unable to install the 2005 client tools (in the event that they would help). I can't afford RedGate, but I really would like to have a database with identical schema on another server.

有什么建议吗?任何简单的.exe(无需安装)工具,技巧或T-SQL技巧都将不胜感激.

Any suggestions? Any simple .exe (no installation required) tools, tips, or T-SQL tricks would be much appreciated.

更新:我正在使用的数据库具有200多个表以及几个外键关系和约束,因此手动编写每个表的脚本并将脚本粘贴在一起并不是一个可行的选择.我正在寻找比此手动解决方案更好的东西

Update: The database I'm working with has 200+ tables and several foreign-key relationships and constraints, so manually scripting each table and pasting together the script is not a viable option. I'm looking for something better than this manual solution

其他更新除非我完全缺少某些东西,否则这不是使用SQL 2000工具的可行解决方案.当我选择在数据库上生成创建脚本的选项时.我最终得到一个包含CREATE DATABASE命令的脚本,并且不创建任何对象-表,约束等.SQL2005的Management Studio也可以处理这些对象,但是数据库处于没有任何对象的环境中我将Management Studio的安装连接到它的方式.

Additional Update Unless I'm completely missing something, this is not a viable solution using the SQL 2000 tools. When I select the option to generate a create script on a database. I end up with a script that contains a CREATE DATABASE command, and creates none of the objects - the tables, the constraints, etc. SQL 2005's Management studio may handle the objects as well, but the database is in an environment where there is no way for me to connect an installation of Management Studio to it.

推荐答案

运行SQL Server Management Studio,右键单击数据库,然后选择Script Database as > Create to > file

Run SQL Server Management Studio, right click on the database and select Script Database as > Create to > file

适用于SQL Server2005.SQLServer 2000企业管理器具有类似的命令.只需右键单击数据库> All Tasks > Generate Scripts.

That's for SQL Server 2005. SQL Server 2000 Enterprise Manager has a similar command. Just right-click on the database > All Tasks > Generate Scripts.

在SQL Server 2005中,可以在对象资源管理器窗格中选择数据库",然后在详细信息窗格中选择多个数据库.然后,右键单击您的选择,然后单击脚本数据库为>创建到>文件".这将导致将它们全部放入一个脚本中,并将包括所有表,键,存储过程和约束.

In SQL Server 2005, you can select "Database" in the object explorer pane and select several databases in the details pane. Then, right-click on your selection and "Script Database as > Create to > file". This will cause it to put them all into one script and it will include all tables, keys, stored procedures, and constraints.

这篇关于有“穷人"吗? RedGate的替代方案,用于编写整个数据库架构的脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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