以编程方式检索 .NET 中的数据库表创建脚本

发布于 2024-07-04 11:54:17 字数 208 浏览 6 评论 0原文

我需要能够检索 CREATE TABLE 脚本,以编程方式(我使用 C#)在 SQL Server (2000) 数据库中重新创建特定表。 显然,您可以使用企业管理器来完成此操作,但我希望将其自动化。

我一直在使用 SQLDMO,它提供了一个备份命令,但我不确定这是否会提供 SQL CREATE TABLE 脚本,并且似乎需要创建 SQL 服务设备,而且我宁愿避免修改数据库。

I need to be able to retrieve a CREATE TABLE script to recreate a specific table in a SQL Server (2000) database, programmatically (I'm using C#). Obviously you can do this with Enterprise Manager but I would like to automate it.

I've been playing around with SQLDMO which offers a Backup command, but I'm not sure if this will give a SQL CREATE TABLE script and seems to require the creation of a SQL Service device, and I would prefer to avoid modifying the database.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤檠 2024-07-11 11:54:17

看看

Take a look at my solution. It's a sql script which uses the INFORMATION_SCHEMA tables to get the necessary information. It's basic, but might work for you.

表情可笑 2024-07-11 11:54:17

您可以使用 SMO 生成脚本。 有关详细信息,请参阅:http://www.sqlteam.com /article/scripting-database-objects-using-smo-updated

You can use SMO to generate the scripts. For more info see: http://www.sqlteam.com/article/scripting-database-objects-using-smo-updated

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文