我有这个sql:
SELECT
sa.answertext
FROM dbo.tblsurveyanswer sa
INNER JOIN dbo.tblsurvey s
ON s.surveyid = sa.surveyid
INNER JOIN dbo.tblquestion q
ON q.questionid = sa.questionid
INNER JOIN dbo.tblshqscriteria c
ON c.shqscriteriaid = q.shqscriteriaid
INNER JOIN dbo.tblshqsdescription d
ON d.shqsdescriptionid = q.shqsdescriptionid
INNER JOIN dbo.tblrepairpercentage rp
ON rp.repairpercentageid = sa.repairpercentageid
WHERE
(c.shqscriteria = 'qwerty')
OR
(c.shqscriteria = 'zxcvb' AND ISNUMERIC(sa.answertext) = 1 AND CAST(sa.answertext AS float) < 5)
我第一次执行它失败,“将数据类型 varchar 转换为浮点数时出错”。第二次*我执行成功 - 因为没有 'qwerty' 或 'zxcvb' shqscriteria,所以不返回任何行
*实际上有时我必须执行多达 8 次才能失败