我在開發使用SQL Server 2005的開發環境,但SQL Server 2000在生產服務器上的應用程序的不幸的情況是。我有一個開發/測試服務器上工作正常,但在生產環境中落在了一個相當複雜的SELECT查詢:多內連接SQL 2000中
SELECT tbl_questions.Question, tbl_questions.QuestionCode
FROM tbl_questions INNER JOIN (
SELECT sg.questioncode, sg.gradeB, sg.gradeA, t2.wt
FROM tbl_scoregrade AS sg INNER JOIN (
SELECT t1.QuestionCode, AVG(1.0 * aw.Weight) AS wt
FROM tbl_AnswerWeight AS aw INNER JOIN (
SELECT assa.QuestionCode, assa.Answer
FROM tbl_AllStaffSurveyAnswers AS assa INNER JOIN
tbl_AllStaffSurvey AS ass ON assa.Questionguid = ass.Questionguid
WHERE (ass.Trust = 'RD7') AND (ass.Specialty = '97'))
AS t1 ON aw.questioncode = t1.QuestionCode AND aw.Response = t1.Answer
GROUP BY t1.QuestionCode)
AS t2 ON sg.questioncode = t2.QuestionCode AND sg.gradeA > t2.wt)
AS t3 ON tbl_questions.QuestionCode = t3.questioncode
你能看見什麼,應該使在不同版本的SQL服務器的運行差異,或事實上,任何情況下都可以簡化查詢?
您可以發佈您收到的錯誤消息嗎? – 2009-08-26 10:15:16
是否與運行SQL的版本相同? – Gavin 2009-08-26 10:18:47