MSBUILD - When executing DDL file I get this error:
Unexpected System.Reflection.TargetInvocationException error executing SQL command
Before this execution two other ones are executed with no problems.
I'm assuming that you're using the ExecuteDDL task from the MSBuild Community Tasks library. If so, I've run into the same issue before and I have always found that the script fails if I run it manually in SQL Management Studio.
I recommend that you run the two scripts that succeeded, then running the on that's failing manually and make sure that it doesn't have any errors.
Related
I have a Visual Studio Database Project, containing whole database. Build passes without errors, but when I try to deploy the DACPAC to a database, the SqlPackage Publish stops on the following error:
An insufficient number of arguments were supplied for the procedure or function
There are some build warnings, but no warning describing the mentioned error.
Why is not the error thrown during build? Why is not the error thrown during build? Why is the error stopping deployment even if the build passed without error? It's too late, it should be catched during build IMHO.
Please is there anything I can do, some settings etc. that catches the error during build?
Thank you.
I have a pipeline Jenkins that execute liquibase scripts. However, lots of time the pipeline failed because there are errors in the script.
I would like to test my script locally before running the pipeline. I would run the script locally to detect if there are errors (syntaxe problem, column that doesn't exist, etc), without creating an entry in the databasechangelog.
One option is to run updateSQL, which will display the sql that liquibase update WOULD run. You can take that sql and run it in any SQL query IDE of your choice to test syntax.
In the build definition in TFS 2015, I've got a Command Line step that runs the following command:
xunit.console.exe \PathToTests\Tests.dll -xml \PathToResultsFolder\Results.xml
During the build, I can see the tests are being discovered and executing and everything's looking good.
But if I don't check "Continue on error" in the Command Line step, after the tests run and the result XML file has been saved, the step fails with the following error:
Task CmdLine failed. This caused the job to fail. Look at the logs for the task for more details.
But there's actually no error or anything I can see. The tests have run and the XML file has saved properly and is able to published to TFS. And I don't see an error like this if I run the command from the build machine.
Any ideas?
I run into this problem - when I run MSBuild task to execute migrations, it throws an error:
While executing migrations the following error was encountered:
Illegal characters in path.
removed the last migration I added yesterday - same problem.
The version I'm using is 1.1.0 from NuGet.
I was running into this error when I was trying to execute some inline sql in my migration.
My problem was that I was using Execute.Script (which expects a file name) instead of Execute.Sql
I am trying to copy a file in my Pre Deployment script for a Visual Studio SQL Database project.
:!!copy $(DataFileDirectory)\data.csv $(DataDestinationDirectory)
I found that this generated the error:
SQL72007: The syntax check failed 'Incorrect syntax near .' in the batch near: ':!!copy
So I tried to simplify my testing and tried:
:!! dir
This also failed:
SQL72007: The syntax check failed 'Incorrect syntax near .' in the batch near: ':!! dir
It fails when I try:
!! dir
I am able to execute commands like:
:r .\myfile.sql
I noticed the following error occurs whenever I do :!!,
72006: Fatal scripting error: Command Execute is not supported.
Why is command execute (:!!) not supported?!
This can, of course, only truly be answered by the designers of SSDT, but you can make an educated guess: it would compromise system security too much. It would allow you to run arbitrary commands on the database server's OS, under the account of the user that runs SQL Server itself.
The sqlcmd.exe command allows one to disable the :!! and :ed commands, using the -X command line option, for the same reason.
If you really need to run OS commands in your script, you could still fallback to xp_cmdshell, which of course also has issues, but at least the server's administrator can decide if it should be allowed.
There are a lot more SQLCMD syntax options, that SSDT pre- or post deployment scripts do not support (for example :connect or :on error, it seems). So, another explanation would be, that for the purpose of deployment scripts the :r and :setvar commands were considered sufficient.