gpt4 book ai didi

sql-server-2008 - 无法解决排序规则冲突

转载 作者:行者123 更新时间:2023-12-04 01:33:58 25 4
gpt4 key购买 nike

我收到以下错误消息。

Cannot resolve the collation conflict between "Latin1_General_CI_AI" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.



只有当我将此代码放在下面的 WHERE 子句中时,我才会得到它。
WHERE Region IN (SELECT Token FROM dbo.getParmsFromString(@Region))

现在@Region 包含来自 SSRS 的多选字段中的所有值。

下面是所使用函数的代码。
CREATE FUNCTION [dbo].[getParmsFromString]
(@String VARCHAR(MAX))
RETURNS @Parms TABLE
(
Token VARCHAR(MAX)
)
AS
BEGIN
IF CHARINDEX(',', @String) != 0
BEGIN
;WITH cte0(Token, List) AS
(
SELECT SUBSTRING(@String, 1, CHARINDEX(',',@String,1) - 1)
,SUBSTRING(@String,CHARINDEX(',',@String,1) + 1, LEN(@String)) + ','

UNION ALL

SELECT SUBSTRING(List,1,ISNULL(CHARINDEX(',',List,1) - 1,1))
,SUBSTRING(List,CHARINDEX(',',List,1) + 1, LEN(List))
FROM cte0
WHERE LEN(cte0.List) > 0
)

INSERT INTO @Parms (Token)
SELECT Token
FROM cte0
OPTION (MAXRECURSION 0)
RETURN;
END

ELSE
INSERT INTO @Parms
SELECT @String
RETURN;
END

最佳答案

尝试改变

 RETURNS @Parms TABLE 
(
Token VARCHAR(MAX)
)


try changing RETURNS @Parms TABLE 
(
Token VARCHAR(MAX) COLLATE DATABASE_DEFAULT
)


WHERE Region IN (SELECT Token FROM dbo.getParmsFromString(@Region))   


WHERE Region COLLATE DATABASE_DEFAULT  IN (SELECT Token FROM dbo.getParmsFromString(@Region))  

关于sql-server-2008 - 无法解决排序规则冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12639163/

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