当我尝试更改我的存储过程(下面)时,我收到此错误消息:
“无法执行将varchar值隐式转换为varchar,因为由于排序规则冲突导致值的排序规则未解决”
此行发生错误:
INSERT INTO @TempList (OrderID) VALUES (@EmpID)
我不明白排序规则存在什么问题。
请关于这个的想法..
由于
USE [database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[database_0301_PRJ_dir_ger]
@EmpList varchar(100)
AS
DECLARE @TempList table (OrderID varchar(10))
DECLARE @EmpID varchar(10)
DECLARE @Pos int
IF @EmpList <> ''
BEGIN
SET NOCOUNT ON
SET @EmpList = LTRIM(RTRIM(@EmpList))+ ','
SET @Pos = CHARINDEX(',', @EmpList, 1)
IF REPLACE(@EmpList, ',', '') <> ''
BEGIN
WHILE @Pos > 0
BEGIN
SET @EmpID = LTRIM(RTRIM(LEFT(@EmpList, @Pos - 1)))
IF @EmpID <> ''
BEGIN
INSERT INTO @TempList (OrderID) VALUES (@EmpID)
END
SET @EmpList = RIGHT(@EmpList, LEN(@EmpList) - @Pos)
SET @Pos = CHARINDEX(',', @EmpList, 1)
END
END
SELECT dir.sigla + '-' + ger.nome AS dirger,
ger.codigo as gercodigo,
ger.nome as gernome,
dir.nome AS dirnome,
ger.diretoria as gerdiretoria
FROM d
bo.database_091500_GERENCIAS AS ger
INNER JOIN
dbo.database_090200_DIRETORIAS AS dir
ON
ger.diretoria = dir.codigo
WHERE
ger.diretoria IN (select * FROM @TempList)
END
答案 0 :(得分:0)
这听起来像语言/国际化的配置问题。
也许您的客户端可能配置为一个区域设置,而您的数据库/数据库服务器可能配置为不同的区域设置?
一种解决方法可能是显式转换,例如:
http://www.sqlservercentral.com/Forums/Topic225939-8-1.aspx#bm225952