如何在 SQL Server 中使用 SQL 查询生成表的创建脚本 [英] How to generate create script of table using SQL query in SQL Server

查看:42
本文介绍了如何在 SQL Server 中使用 SQL 查询生成表的创建脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的实时数据库中生成已创建表的创建表脚本.

I want to generate create table script of already created table in my live database.

我知道我们可以使用右键单击表并单击脚本表为"菜单来生成脚本,然后将生成脚本.因为我的实时数据库 UI 运行速度很慢.

I know we can generate scripts using right click on table and click on 'script table as' menu and script will be generated. Because my live db UI is running very slow.

我想使用 SQL 查询执行相同的过程.有什么办法吗??

I want to do same process using SQL query. is there any way??

推荐答案

如果您正在寻找 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)

(我最初在这里回答了这个问题,但仅限 SQL Server 的开发人员可能不会将问题标题与此问题联系起来)

(I originally answered this here, but SQL Server-only devs probably do not relate the question title to this problem)

这篇关于如何在 SQL Server 中使用 SQL 查询生成表的创建脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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