Search code examples
databasevisual-studio-2013sql-server-data-toolsdatabase-projectdacpac

How I know any particular one command is failed while deploying/publishing data in Database?


I have created database project in visual studio 2013. Project build successfully . In this project I have inserted some test data in post deployment. If any data failed to insert then how can know the one of script is failed at particular location.

Actually I want to rollback all the thing if any command is failed from script file itself. Since SQL Server 2012 is not supporting rollback from pre/post deployment script.


Solution

  • The result window will give you the line and details of any error, it is a bit annoying as it will sometimes show the text of the beginning of the script but the error line number will be correct.

    General things you should do is to make sure your insert scripts are re-runnable and then if you really can't see the error you can run the script yourself to debug it.

    I would really recommend using MERGE statements to do the inserts :)

    I also generally recommend using sqlpackage.exe to push to local Deb instances rather than the vs publish, see:

    https://the.agilesql.club/blog/Ed-Elliott/Visual-Studio-SSDT-Publish-My-Personal-Best-Practices

    Ed