diff --git a/Providers/FreeSql.Provider.Custom/SqlServer/Curd/CustomSqlServerUpdate.cs b/Providers/FreeSql.Provider.Custom/SqlServer/Curd/CustomSqlServerUpdate.cs index dc02dfcae..3811c04d8 100644 --- a/Providers/FreeSql.Provider.Custom/SqlServer/Curd/CustomSqlServerUpdate.cs +++ b/Providers/FreeSql.Provider.Custom/SqlServer/Curd/CustomSqlServerUpdate.cs @@ -90,7 +90,7 @@ protected override void ToSqlCase(StringBuilder caseWhen, ColumnInfo[] primarys) foreach (var pk in primarys) { if (pkidx > 0) caseWhen.Append(" + '+' + "); - caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar)"); + caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar(2000))"); ++pkidx; } caseWhen.Append(")"); @@ -107,7 +107,7 @@ protected override void ToSqlWhen(StringBuilder sb, ColumnInfo[] primarys, objec foreach (var pk in primarys) { if (pkidx > 0) sb.Append(" + '+' + "); - sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar)"); + sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar(2000))"); ++pkidx; } } diff --git a/Providers/FreeSql.Provider.Odbc/SqlServer/Curd/OdbcSqlServerUpdate.cs b/Providers/FreeSql.Provider.Odbc/SqlServer/Curd/OdbcSqlServerUpdate.cs index c0a07c188..b131cf71a 100644 --- a/Providers/FreeSql.Provider.Odbc/SqlServer/Curd/OdbcSqlServerUpdate.cs +++ b/Providers/FreeSql.Provider.Odbc/SqlServer/Curd/OdbcSqlServerUpdate.cs @@ -90,7 +90,7 @@ protected override void ToSqlCase(StringBuilder caseWhen, ColumnInfo[] primarys) foreach (var pk in primarys) { if (pkidx > 0) caseWhen.Append(" + '+' + "); - caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar)"); + caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar(2000))"); ++pkidx; } caseWhen.Append(")"); @@ -107,7 +107,7 @@ protected override void ToSqlWhen(StringBuilder sb, ColumnInfo[] primarys, objec foreach (var pk in primarys) { if (pkidx > 0) sb.Append(" + '+' + "); - sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar)"); + sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar(2000))"); ++pkidx; } } diff --git a/Providers/FreeSql.Provider.SqlServer/Curd/SqlServerUpdate.cs b/Providers/FreeSql.Provider.SqlServer/Curd/SqlServerUpdate.cs index 1dd7a5e0a..ae4710db4 100644 --- a/Providers/FreeSql.Provider.SqlServer/Curd/SqlServerUpdate.cs +++ b/Providers/FreeSql.Provider.SqlServer/Curd/SqlServerUpdate.cs @@ -90,7 +90,7 @@ protected override void ToSqlCase(StringBuilder caseWhen, ColumnInfo[] primarys) foreach (var pk in primarys) { if (pkidx > 0) caseWhen.Append(" + '+' + "); - caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar)"); + caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar(2000))"); ++pkidx; } caseWhen.Append(")"); @@ -107,7 +107,7 @@ protected override void ToSqlWhen(StringBuilder sb, ColumnInfo[] primarys, objec foreach (var pk in primarys) { if (pkidx > 0) sb.Append(" + '+' + "); - sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar)"); + sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar(2000))"); ++pkidx; } }