我正在使用 Microsoft SQL Server Management Studio 2008,但在创建视图时遇到了问题。我有以下代码:
;WITH
cteSample
AS (
SELECT
vw_JobCosting_WIPMasterSub.SJob
, vw_JobCosting_WIPMasterSub.MJob
, vw_JobCosting_WIPMasterSub.MJob DisplayMJob
, vw_JobCosting_WIPMasterSub.GroupF
, 0 AS LVL
FROM vw_JobCosting_WIPMasterSub
WHERE vw_JobCosting_WIPMasterSub.GroupF = 'True'
UNION ALL
SELECT
vw_JobCosting_WIPMasterSub.SJob
, vw_JobCosting_WIPMasterSub.MJob
, CASE S.LVL
WHEN 0 THEN S.SJob
ELSE S.DisplayMJob
END AS DisplayMJob
, vw_JobCosting_WIPMasterSub.GroupF
, S.LVL + 1
FROM cteSample S
INNER JOIN vw_JobCosting_WIPMasterSub
ON S.SJob = vw_JobCosting_WIPMasterSub.MJob
WHERE vw_JobCosting_WIPMasterSub.GroupF = 'False'
)
SELECT
cteSample.SJob
, cteSample.DisplayMJob MJob
, cteSample.GroupF
FROM cteSample
ORDER BY
cteSample.LVL
, cteSample.MJob
, cteSample.SJob
此代码作为查询执行得很好。当我作为视图执行时,我收到消息:
“无法解析查询文本”
当我确定时,代码执行良好。当我尝试保存时,我收到以下错误并且它不会保存:
“';' 附近的语法不正确”
任何帮助将不胜感激。