How can I generate a script of my database as it is?

前端 未结 6 1557
孤街浪徒
孤街浪徒 2021-02-02 17:18

My primary reason for this is to keep track of database schema changes for my application. In SQL Server Management Studio I am able to generate a create script which creates t

6条回答
  •  粉色の甜心
    2021-02-02 17:53

    I wrote an open source command line utility named SchemaZen that does this. It's much faster than scripting from management studio and it's output is more version control friendly. It supports scripting both schema and data.

    To generate scripts run:

    schemazen.exe script --server localhost --database db --scriptDir c:\somedir

    Then to recreate the database from scripts run:

    schemazen.exe create --server localhost --database db --scriptDir c:\somedir

提交回复
热议问题