Thursday, August 23, 2012

SQL Server Database Project - Warning is shown as Error

While trying to build a database project, I was getting an error:
Error:  SQL01945: Warning! The maximum key length is 900 bytes. The index 'xxx' has maximum length of 1024 bytes. For some combination of large values, the insert/update operation will fail.

Although this was a warning, the project was failing to build and it was shown as a error.

The fix was to edit the project file in xml and set TreatTSqlWarningsAsErrors to False

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <OutputPath>.\sql\debug\</OutputPath>
    <BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
    <TargetDatabase>xxx</TargetDatabase>
    <TreatTSqlWarningsAsErrors>False</TreatTSqlWarningsAsErrors>
    <SuppressTSqlWarnings />
    <NoWarn>
    </NoWarn>
  </PropertyGroup>

No comments:

Post a Comment