Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making SSDT just generate a SQL script (and not deploy a database)

Having recently upgraded to SSDT 2012 I seem to be missing the option to just generate a T-SQL script instead of deploying the database to a server somewhere.

To be more accurate the predecessor to SSDT used to set the Deploy action to 'Generate script', but I cannot locate that option anywhere in the new version.

Is it possible?

like image 831
noonand Avatar asked Apr 05 '12 16:04

noonand


People also ask

How do you turn a database into a script?

In the SQL Server Management Studio, expand Databases, and then locate the database that you want to script. Right-click the database, point to Script Database As, then point to CREATE To, and then select File. Enter a file name, and then select Save.


2 Answers

To generate a script from an offline data project in SSDT rather than deploy to a target database, configure the project settings as shown below

SSDT deployment configuration dialogue boxes

like image 122
Lynn Langit Avatar answered Sep 19 '22 01:09

Lynn Langit


You may want to look at the SQLPackage command line. You can set the options there to use an action of "script" and specify an outputfile name to generate scripts instead of publishing the database. You can also do that through a batch file so it will generate a script every time. You still need to provide a source project and target database, though. The reference for SQLPackage can be found here: http://msdn.microsoft.com/en-us/library/hh550080%28v=VS.103%29.aspx

like image 36
Peter Schott Avatar answered Sep 20 '22 01:09

Peter Schott