大家好我有以下存儲過程SQL服務器轉換爲varchar字符串爲int
SELECT DISTINCT QuestionId, AnswerId, COUNT(AnswerId) AS Cntr,
(SELECT COUNT(AnswerId) AS ttl
FROM QUserAnswers
WHERE (QuestionId = QUAM.QuestionId)) AS TtlCnt
FROM QUserAnswers AS QUAM
WHERE (QuestionId IN (@QuestionIdIn))
GROUP BY QuestionId, AnswerId
ORDER BY QuestionId
我在@QuestionIdI
傳遞格式「1,2,3,4,5'
然而,它的投擲VARCHAR值'1,2,3,4,5,6'
轉換時轉換失敗的錯誤數據類型int
。
任何人都可以給我一些指點,如果你擔心服務表現理清
您正在使用什麼版本的SQL Server? http://www.sommarskog.se/arrays-in-sql-2005.html – 2012-07-26 11:25:04