Sql server 查询中的SQL Server整理错误

Sql server 查询中的SQL Server整理错误,sql-server,Sql Server,我到处找人帮忙,但似乎什么都没用 我在SP中有以下语句,每次都会因collate错误而失败: INSERT INTO #TableR (id, email, forename, Age, gender) SELECT TOP 1 #TEMPMDUK.id AS [id], email, forename, Age, gender FROM #TEMPMDUK WHERE SUBSTRING(postcode, 0, (CHARINDEX(' ', postcode, 0)+2)) i

我到处找人帮忙,但似乎什么都没用

我在SP中有以下语句,每次都会因collate错误而失败:

INSERT INTO #TableR (id, email, forename, Age, gender) 
SELECT TOP 1 #TEMPMDUK.id AS [id], email, forename, Age, gender 
  FROM #TEMPMDUK 
 WHERE SUBSTRING(postcode, 0, (CHARINDEX(' ', postcode, 0)+2)) in  (select Postcode from LiveTable) 
   and not #TEMPMDUK.ID in (SELECT id FROM #Excludelist) 
   and #TEMPMDUK.ID in (SELECT id FROM #Includelist) 
ORDER BY NEWID() 
我们在声明中添加了以下条款后,才开始出现这种情况:

WHERE SUBSTRING(postcode, 0, (CHARINDEX(' ', postcode, 0)+2)) in  (select Postcode from LiveTable)
如果我们在select语句中将其作为子句运行,一切正常,但当我们将其放入SP中的INSERT语句时,它会中断


如果您能帮助解决此问题,我们将不胜感激。我不知道您的表结构,但您的列中似乎有不同的排序规则。试着玩

SELECT TOP 1 #TEMPMDUK.id AS [id], email COLLATE Latin1_General_CI_AS, forename, Age, gender 


应该是。。。。而TEMPMDUK.ID不从Excludelist中插入select ID…可能是您需要将整个子字符串转换为INT。假设邮政编码为数字。粘贴准确的错误消息抱歉,这是我们收到的消息:Msg 468,级别16,状态9,过程电子邮件D6605 Suzuki Celerio,第103行无法解决“等于”操作中SQL_Latin1_General_CP1_CI_AS和Latin1_General_CI_AS之间的排序规则冲突。
SELECT TOP 1 #TEMPMDUK.id AS [id], email COLLATE SQL_Latin1_General_CP1_CI_AS, forename, Age, gender