如何为包含所有存储行的现有 SQL Server 表生成 INSERT 脚本? [英] How can I generate an INSERT script for an existing SQL Server table that includes all stored rows?
问题描述
我正在寻找一种使用 SQL Management Studio 2008 R2 生成创建并插入所有行"脚本的方法.
I'm looking for a way to generate a "Create and insert all rows" script with SQL Management Studio 2008 R2.
我知道我可以创建一个创建表"脚本.
I know that I can create a "create table" script.
我也可以创建一个插入"脚本,但这只会生成带有占位符的单行.
I can also create an "insert in" script, but that will only generate a single row with placeholders.
有没有办法生成包含当前存储的所有行的插入脚本?
Is there a way to generate an insert script that contains all currently stored rows?
推荐答案
可以,但您需要在数据库级别运行它.
Yes, but you'll need to run it at the database level.
在 SSMS 中右键单击数据库,选择任务"、生成脚本...".完成后,您将进入脚本选项"部分.单击高级",然后在弹出的列表中显示要编写脚本的数据类型",您可以选择数据和/或架构.
Right-click the database in SSMS, select "Tasks", "Generate Scripts...". As you work through, you'll get to a "Scripting Options" section. Click on "Advanced", and in the list that pops up, where it says "Types of data to script", you've got the option to select Data and/or Schema.
这篇关于如何为包含所有存储行的现有 SQL Server 表生成 INSERT 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!