1. 程式人生 > >SQL Server知識總結及常用命令

SQL Server知識總結及常用命令

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