如何在 DML(SQL 脚本)中从 SQL Server 2008.2010 导出数据? [英] How to export data from SQL Server 2008.2010 in DML (SQL script)?

查看:31
本文介绍了如何在 DML(SQL 脚本)中从 SQL Server 2008.2010 导出数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有工具或特殊查询可以做到这一点.我不是数据库管理员.

Is there a tool or special query to do that. I'm not an database administrator.

推荐答案

以下是从数据库和数据生成脚本的步骤.屏幕截图是使用 SQL Server 2012 Management Studio 截取的,但我相信 SQL Server 2008 的步骤也类似.

Here are the steps to generate the scripts from a database along with data. The screenshots were taken using SQL Server 2012 Management Studio but I believe that the steps are similar for SQL Server 2008 as well.

  • 连接到您希望将数据库与数据一起编写脚本的实例.
  • 右键单击数据库并选择选项Tasks -->生成脚本...

  • 生成和发布脚本向导中,点击Next按钮.
  • On the Generate and Publish Scripts wizard, click Next button.

  • 选择对象步骤中,我保留了默认选择编写整个数据库和所有数据库对象的选中状态.您还可以选择选项 Select specific database objects 并选择您选择的对象.
  • On the Choose objects step, I have left the default selection Script entire database and all database objects checked. You can also select the option Select specific database objects and pick the objects of your choice.

  • 设置脚本选项步骤中,选择要保存脚本的路径.点击高级按钮.
  • On the Set Scripting Options step, select the path where you would like to save the script. Click on the Advanced button.

  • 高级脚本选项对话框中,向下滚动到选项脚本的数据类型.默认情况下,它设置为 Schema only,这意味着它将只生成 create object 语句.如果您需要对象创建脚本和数据,请选择选项Schema and data.在高级脚本选项对话框中单击确定,然后在设置脚本选项步骤
  • 中单击下一步
  • On the Advanced Scripting Options dialog, scroll down to the option Types of data to script. By default, this is set to Schema only, which means it will generate only the create object statements. If you want both object creation script along with data, select the option Schema and data. Click OK on the Advanced Scripting Options dialog and click Next on the Set Scripting Options step

  • Summary 步骤中,它将显示您选择的所有选项.点击下一步.
  • On the Summary step, it will show all the options that you had selected. Click Next.

  • 保存或公开脚本步骤中,如果一切顺利,您将看到针对每个对象出现成功状态,并且脚本应保存到您在设置脚本中指定的位置选项步骤.
  • On the Save or Publich Scripts step, if everything goes well you will see Success status appear against each object and the script should be saved to the location that you specified on the Set Scripting Options step.

编写整个 AdventureWorks 数据库的脚本变成了一个巨大的 522 MB 脚本文件!

Scripting the entire AdventureWorks database turned to be a huge 522 MB script file!

希望有所帮助.

这篇关于如何在 DML(SQL 脚本)中从 SQL Server 2008.2010 导出数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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