使用 SQL Server Server Management Studio 导入/导出数据库

2021-12-25 00:00:00 import export sql-server ssms

我认为这很简单,但事实并非如此...我确定有一种简单的方法可以做到,但我无法找到它.为我感到羞耻.

我想导入/导出数据库本身、表、约束(外键等).我宁愿不拿数据,但如果没有其他办法,我可以摆脱它.

I want to import/export the database itself, the tables, the constraints (foreign keys and so on). I'd rather not get the data with it, but I can get rid of it after if there's no other way.

那么……您如何使用 MS SQL Server Management Studio 导出数据库?你如何导入它?

So... how do you export a database using MS SQL Server Management Studio ? How do you import it?

我找到的唯一解决方案是右键单击表格并创建脚本",但我有大约 100 个表格,所以我宁愿避免这种情况.

The only solution I found was right click on the tables and "script to Create", but I have something like 100 tables, so I'd rather avoid this.

谢谢!

推荐答案

右键单击数据库本身,Tasks -> Generate Scripts...

Right click the database itself, Tasks -> Generate Scripts...

然后按照向导操作.

对于 SSMS2008+,如果您还想导出数据,请在设置脚本选项"步骤中,选择高级"按钮并将脚本的数据类型"从仅架构"更改为仅数据"或架构和数据".

For SSMS2008+, if you want to also export the data, on the "Set Scripting Options" step, select the "Advanced" button and change "Types of data to script" from "Schema Only" to "Data Only" or "Schema and Data".

相关文章