Share via


Database Project - Generate Script

Question

Wednesday, January 17, 2018 3:48 PM

Visual studio database project offers Generate Script and its also creates an incremental DB changes.

Can I generate scripts using msbuild or command line or any other third party component.

All replies (1)

Friday, January 19, 2018 8:30 AM

Hi satyajit015,

Thanks for posting here.

Do you mean generate the publish script based on the generated dacpac file and the actual database? If yes, you can use SqlPackage.exe. Look for it on your machine in a directory with a name similar to this:

C:\Program Files (x86)\Microsoft SQL Server\130\DAC\bin

Note that it may be found in the 110, 120 or 130 folder.

If you don't have SqlPackage.exe already, you can download it from here: https://www.microsoft.com/en-us/download/details.aspx?id=51941

If you download it, be sure to look in the System Requirements section of the download page to find the dependencies SqlSysClrTypes.msi and SqlDom.msi, which must be installed as well.

Example usage:

SqlPackage.exe /a:script /SourceFile:C:\temp\mydb.dacpac /TargetConnectionString:"Data Source=myserver;Initial Catalog=mydb;Integrated Security=true" /OutputPath:C:\temp

For some more detailed info, you can refer to:

https://stackoverflow.com/questions/45943575/build-and-generate-script-for-ssdt-project-using-command-line-tools

Hope this helps.

MSDN Community Support Please remember to click Mark as Answer. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].