Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Script out schema in SQL Server

I want to create a schema in SQL Server database. There are also bunch of other scripts in the database. Can I script out an existing schema? I mean, suppose we have a table, we can script out a CREATE TABLE script? Can we script out a Create Schema.

Thanking You Guys in Anticipation,

like image 822
SaiBand Avatar asked Dec 22 '22 16:12

SaiBand


1 Answers

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
like image 166
Seth Reno Avatar answered Mar 11 '23 04:03

Seth Reno