gpt4 book ai didi

sql-server - 无法解决等于操作中 "SQL_Latin1_General_CP1_CI_AS"和 "Latin1_General_CI_AS"之间的排序规则冲突

转载 作者:搜寻专家 更新时间:2023-10-30 20:52:08 25 4
gpt4 key购买 nike

我有以下代码

SELECT tA.FieldName As [Field Name],
COALESCE(tO_A.[desc], tO_B.[desc], tO_C.Name, tA.OldVAlue) AS [Old Value],
COALESCE(tN_A.[desc], tN_B.[desc], tN_C.Name, tA.NewValue) AS [New Value],
U.UserName AS [User Name],
CONVERT(varchar, tA.ChangeDate) AS [Change Date]
FROM D tA
JOIN
[DRTS].[dbo].[User] U
ON tA.UserID = U.UserID
LEFT JOIN
A tO_A
on tA.FieldName = 'AID'
AND tA.oldValue = CONVERT(VARCHAR, tO_A.ID)
LEFT JOIN
A tN_A
on tA.FieldName = 'AID'
AND tA.newValue = CONVERT(VARCHAR, tN_A.ID)
LEFT JOIN
B tO_B
on tA.FieldName = 'BID'
AND tA.oldValue = CONVERT(VARCHAR, tO_B.ID)
LEFT JOIN
B tN_B
on tA.FieldName = 'BID'
AND tA.newValue = CONVERT(VARCHAR, tN_B.ID)
LEFT JOIN
C tO_C
on tA.FieldName = 'CID'
AND tA.oldValue = tO_C.Name
LEFT JOIN
C tN_C
on tA.FieldName = 'CID'
AND tA.newValue = tN_C.Name
WHERE U.Fullname = @SearchTerm
ORDER BY tA.ChangeDate

运行代码时,在为表 C 添加两个连接后,我在标题中粘贴了错误。我认为这可能与我正在使用 SQL Server 2008 并已恢复此副本的事实有关db 到我 2005 年的机器上。

最佳答案

我做了以下事情:

...WHERE 
fieldname COLLATE DATABASE_DEFAULT = otherfieldname COLLATE DATABASE_DEFAULT

每次都有效。 :)

关于sql-server - 无法解决等于操作中 "SQL_Latin1_General_CP1_CI_AS"和 "Latin1_General_CI_AS"之间的排序规则冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38726923/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com