SQL Server 等效于 DBMS_METADATA.GET_DDL [英] SQL Server equivalent to DBMS_METADATA.GET_DDL

查看:36
本文介绍了SQL Server 等效于 DBMS_METADATA.GET_DDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 SQL Server 2008 中是否有与 Oracle 的 DBMS_METADATA.GET_DDL 函数等效的函数?您可以向此函数传递一个表名,它会返回该表的 ddl,以便您可以使用它为架构构建脚本.

I was wondering if there is an equivalent in SQL Server 2008 to Oracle's DBMS_METADATA.GET_DDL Function? You can pass this function a table name and it will return the ddl for that table so that you can use it to build a script for a schema.

我知道我可以进入 SSMS 并使用它,但我更喜欢有一个 t-sql 脚本来为我生成 ddl.

I know I can go into SSMS and use that, but I would prefer to have a t-sql script that would generate the ddl for me.

谢谢,

S

推荐答案

如果您正在寻找 TSQL 解决方案,它非常冗长,如 [本示例]¹ 所示.

If you are looking for a TSQL solution, it is quite verbose, as [this example]¹ shows.

更短的替代方法是使用 SMO 库(示例)

A shorter alternative would be using the SMO library (example)

¹ 此示例的链接已删除.Internet Archive Wayback Machine 显示错误的方式说他们无法显示内容.并按照原始链接到某个地方是恶意的.(严重错误、拨打某个号码的指令等)

¹ Link for this example deleted. The way Internet Archive Wayback Machine displayed an error saying that they could not display the content. And following the link to the original went someplace malicious. (Grave errors, instruction to call some number, etc.)

这篇关于SQL Server 等效于 DBMS_METADATA.GET_DDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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