DrJohnT / AzureDevOpsExtensionsForSqlServer

Microsoft SQL Server deployment extensions for Azure DevOps Pipelines
MIT License
20 stars 14 forks source link

sql execution getting failed if Data already present #42

Closed thamulansar closed 2 years ago

thamulansar commented 2 years ago

$Command = "Invoke-Sqlcmd -ServerInstance '$Server' -Database '$Database' -InputFile '$SqlCmdFile' -OutputSqlErrors 1 -ErrorAction Stop";

Scenario : lets say 5 SQL insertion task is there inside the folder as 5 files. If issue with first SQL command file , Second command wont run and throw error example ::: Cannot insert duplicate key in object 'dbo.Table_TEST'. The duplicate key value

So next sql cmd wont run in the for loop.

Please have a check. Thanks

DrJohnT commented 2 years ago

Deployment scripts should always error when a script errors. That way you know when something has gone wrong. Hence the code has -ErrorAction Stop

Do deal with this

Ultimately, think about what you are doing before raising non-issues.