我一直在寻找这方面的帮助,但似乎没有任何效果。
我在SP中有以下语句,每次都失败并出现整理错误:
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语句时它会中断。
非常感谢您解决此问题的任何帮助。
答案 0 :(得分:0)
我不知道你的表结构,但似乎你在列中有不同的排序规则。尝试玩
SELECT TOP 1 #TEMPMDUK.id AS [id], email COLLATE Latin1_General_CI_AS, forename, Age, gender
或
SELECT TOP 1 #TEMPMDUK.id AS [id], email COLLATE SQL_Latin1_General_CP1_CI_AS, forename, Age, gender