我正在使用以下查询,需要指定排序提示以避免跨数据库的排序问题,因为此查询使用来自2个不同数据库的表。
Msg 468, Level 16, State 9, Line 12 Cannot resolve the collation conflict between "Latin1_General_CS_AI" and "Latin1_General_CS_AS" in the equal to operation.
当我运行一些使用具有不同排序规则的不同数据库的查询时,当前出现了上述的排序冲突错误:
Delete from table1 where oldcolumn in
(
select newcolumn from Database2.dbo.table2
where invoiceid = @invno
and complete = 0
)
我将查询更改为包含如下排序提示:
Delete from table1 where oldcolumn COLLATE SQL_Latin1_General_CP1_CS_AS in
(
select newcolumn from Database2.dbo.table2
where invoiceid = @invno
and complete = 0
)
- 以上查询是否能解决排序问题?
- 在运算符(例如“=”)的左侧或右侧指定字符集提示是相同的吗?
- 像
invoiceid = @invno
这样的查询会生成运行时字符集冲突错误吗?
注意: 我提出这个问题是因为我没有访问上述两个数据库的权限,并且该脚本将在实际数据库上运行。
table2
返回newcolumn = 'résumé'
时,您需要删除oldcolumn = 'resume'
吗?或者反之亦然? - Quassnoiinvoiceid
和@invno
是哪种类型? - Quassnoi