SQL Server复制全表定义

编程入门 行业动态 更新时间:2024-10-27 02:22:23
本文介绍了SQL Server复制全表定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在SQL Server的企业版中,可以通过使用脚本表为创建为来为现有表生成create语句。这将为包含索引的表生成完整的create语句。是否可以在T-SQL中执行任何操作,从而将表定义复制到新表中?

In the Enterprise version of SQL Server it is possible to generate the create statement for a pre-existing table by using 'Script Table as', "Create to". This generates the full create statement for the table including indices. Is there any way to do this in T-SQL and therefore be able to copy a table definition to a new table?

推荐答案

可以直接复制SSMS功能的直接T-SQL中没有开箱即用的东西。

Nothing simply available out of the box in straight T-SQL which exactly replicates what SSMS does.

但是,您可以通过元数据( INFORMATION_SCHEMA.COLUMNS 等),我已经相当成功地做到了。请注意,索引不在 INFORMATION_SCHEMA 中,而是在sys.indexes中。

However, you can get to this through the metadata (INFORMATION_SCHEMA.COLUMNS etc), and I have done this fairly successfully. Note that the indexes are not in INFORMATION_SCHEMA - they are in sys.indexes.

看看本文,其中可能包含您想要的大部分内容。

Have a look at this article which probably has most of what you want.

更多推荐

SQL Server复制全表定义

本文发布于:2023-10-20 01:16:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1509395.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:定义   SQL   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!