简体   繁体   English

我可以在 SQL Server 2005 任务中自动“生成脚本”吗?

[英]Can I automatically 'Generate Scripts' in a SQL Server 2005 task?

I'd like to automatically generate database scripts on a regular basis.我想定期自动生成数据库脚本。 Is this possible.这可能吗。

To generate script for an object you have to pass up to six parameters:要为对象生成脚本,您必须传递最多六个参数:

exec proc_genscript 
    @ServerName = 'Server Name', 
    @DBName = 'Database Name', 
    @ObjectName = 'Object Name to generate script for', 
    @ObjectType = 'Object Type', 
    @TableName = 'Parent table name for index and trigger',
    @ScriptFile = 'File name to save the script'

http://www.databasejournal.com/features/mssql/article.php/2205291 http://www.databasejournal.com/features/mssql/article.php/2205291

You might want to look at the SQL Server Management Objects (SMO).您可能想查看 SQL Server 管理对象 (SMO)。 There are objects for scripting that will assist in generating T-SQL scripts from database objects.有一些脚本对象可以帮助从数据库对象生成 T-SQL 脚本。 A good reference for this is "Programming SQL Server 2005" by Bill Hamilton. Bill Hamilton 的“Programming SQL Server 2005”是一个很好的参考。 Chapter 12 in particular references the SMO utility classes.第 12 章特别提到了 SMO 实用程序类。

You can use the Database Publishing Wizard , from CodePlex. 您可以使用CodePlex中的数据库发布向导 It has a command-line interface. 它有一个命令行界面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 SQL Server Management Studio 2008 中自动执行“生成脚本”任务? - How can I automate the “generate scripts” task in SQL Server Management Studio 2008? SQL Server - 如何自动“生成和发布脚本” - SQL Server - how to “Generate and Publish Scripts” automatically 如何生成将使用数据重建MS SQL Server 2005数据库的脚本? - How do I generate scripts that will rebuild my MS SQL Server 2005 database with data? 通过在SQL Server中提供对象名称来自动生成脚本 - Generate scripts automatically by giving object names in sql server 部署脚本的Sql Server 2005事务 - Sql Server 2005 Transactions For Deployment Scripts 我可以在SQL Server 2008上还原SQL Server 2005备份吗? - Can I restore a SQL Server 2005 backup on SQL Server 2008? 我可以在SQL Server 2005上开发并部署到SQL Server 2000吗? - Can I develop on SQL Server 2005 and deploy to SQL Server 2000? 如何在带有图形数据库对象的 SQL Server 2017 中使用“生成脚本”? - How can I use 'Generate Scripts' in SQL Server 2017 with Graph Database Objects? 生成脚本SQL Server 2008 - Generate scripts SQL Server 2008 SQL Server 2005中的临时表不会自动删除 - Temp tables in SQL Server 2005 not automatically dropped
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM