1、获得表或者数据库的ddl
有的时候想把某个表的ddl导出,方法如下:选中表,点击右键,选择“Script Table as”-》“Create To”,选中文件或者剪贴板,当然还有一些别的选项。
如果想把一个数据库里的表都导出,有一个便利的方法:
Right-click on the Database, select Tasks
and then Generate Scripts
, which will launch the Script Wizard. This allows you to generate a single script that can recreate the full database including table/indexes & constraints/stored procedures/functions/users/etc. There are a multitude of options that you can configure to customise the output, but most of it is self explanatory.
If you are happy with the default options, you can do the whole job in a matter of seconds.
If you want to recreate the data in the database (as a series of INSERTS) I'd also recommend SSMS Tools Pack (Free).
http://stackoverflow.com/questions/5771047/create-sql-script-that-create-database-and-tables