Skip to content

Instantly share code, notes, and snippets.

@anova
Last active November 3, 2022 20:31
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save anova/a0edec2f814ef1db9a44ac370df24248 to your computer and use it in GitHub Desktop.
Save anova/a0edec2f814ef1db9a44ac370df24248 to your computer and use it in GitHub Desktop.
Sqlpackage.exe samples

Export

Creates a .bacpac file from live database.

"C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe" /a:Export /scs:"Data Source=SERVER;Initial Catalog=db_name;Integrated Security=False;Persist Security Info=False;User ID=db_user;Password=db_password" /tf:"D:\backup\database_backup.bacpac"

Import

Import from .bacpac file to database.

"C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe" /a:Import /sf:D:\backup\database_backup.bacpac /tcs:"Server=.\SQLEXPRESS;Database=db_name;Trusted_Connection=True;"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment