This project is read-only.

SqlCmd and SeverityLevel and ContinueOnError question

Nov 8, 2010 at 9:38 PM

I can't seem to get my sqlcmd to fail my tfs build.I have 4 input scripts with one having the following error:

"Msg 3725, Level 16, State 0, Line 1
The constraint 'x' is being referenced by table 'y', foreign key constraint 'FK_z'
.Msg 3727, Level 16, State 0, Line 1
Could not drop constraint. See previous errors.
Msg 1779, Level 16, State 0, Line 1
Table 'z' already has a primary key defined on it.
Msg 1750, Level 16, State 0, Line 1Could not create constraint. See previous errors."

And I use the following sqlcmd attributes: ContinueOnError="false" QueryTimeout="65535" SeverityLevel="16"
I get the following output:  warning : "Exit Code 1. Failure: " but no errors are logged and the build continues when I believe it shouldn't. Any ideas?

I'm using Sql 2008.

Nov 9, 2010 at 9:51 AM


Any chance you can email me a repro sql script?


Jan 11, 2011 at 9:26 PM

Has there been any word on this?  I'm having the same issue as stated above.


SeverityLevel, ContinueOnError and other possible solutions have come up with nothing.  Seems as though MSBuild is converting the error to a warning regardless of the properties you set.

Error I'm receiving from the script output file:  The DELETE statement conflicted with the REFERENCE constraint "FK_xxx". The conflict occurred in database "xxx", table "xxx", column 'xxx'. The statement has been terminated.

Error/Warning in my MSBuild log file:  J:\Product - AT_MR\Database\BuildType\TFSBuild.proj : warning : Exit Code 1. Failure:

Code in TFSBuild.proj file: <SqlCmd TaskAction="Execute" Server="$(RemoteServer)" Database="$(RemoteDB)" InputFiles="@(InputFile)" QueryTimeout="240" OutputFile="J:\$(BuildNumber)\Script_Output.txt" SeverityLevel="0" />


Jan 11, 2011 at 11:45 PM

Thanks for the feedback. I can repro this on SQL 2008 R2. I'm not sure why it's started behaving like this. I'll investigate and see what can be done. ETA is around a week as I'm a bit stretched for time this week.


Jan 11, 2011 at 11:47 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Jan 12, 2011 at 8:33 AM

If I use SeverityLevel="5" rather than 0, then it works. You need to provide a SeverityLevel > 0

"C:\a\SqlCmd.proj" (default target) (1) ->(Default target) ->  C:\a\SqlCmd.proj(4,5): error : SeverityLevel: 5 has been met or exceeded: 16

Jan 12, 2011 at 9:11 AM

I tied 16 and it still didn't work.

Sent from my HTC

On Jan 12, 2011 6:33 PM, "mikefourie" <> wrote:
> From: mikefourie
> If I use SeverityLevel="5" rather than 0, then it works. You need to provide a SeverityLevel > 0"C:\a\SqlCmd.proj" (default target) (1) ->(Default target) -> C:\a\SqlCmd.proj(4,5): error : SeverityLevel: 5 has been met or exceeded: 16
Jan 12, 2011 at 9:25 AM

That's odd. If you can supply some repro scripts that would be appreciated.