且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-10-18 10:49:55

右键点击数据库本身,任务 - >生成脚本...



然后按照向导。



对于SSMS2008 +,if您还要导出数据,在设置脚本选项步骤中,选择高级按钮,并将数据类型到脚本从仅限模式更改为仅数据或模式和数据。 / p>

I thought this would be trivial, but it isn't... I'm sure there is a simple way to do it but I can't manage to find it. Shame on me.

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.

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

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.

Thanks!

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

Then follow the wizard.

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".