创建视图时解析错误

时间:2012-10-31 12:13:22

标签: sql sql-server-2008

我有一个视图,它从表列中获取多行和逗号分隔值(CSV)和数据。

效果很好,我得到了我需要的结果。现在视图有一些解析错误,如:

  

WHERE子句中的错误'('。无法解析查询文本。

有人可以帮忙吗?这是我的代码:

SELECT dbo.table1.title,
       Stuff((SELECT ', ' + CONVERT(NVARCHAR(4000), dbo.table3.uid) AS [text()]
              FROM   dbo.table2
                     INNER JOIN dbo.table3
                       ON dbo.table3.uid = dbo.table2.FK_Group
              WHERE  dbo.table3.uid = dbo.table2.FK_Group
                     AND dbo.table3.company = dbo.main.company
                     AND dbo.table2.FK_Version = dbo.table1.fk_Version
                     AND dbo.main_version.uid = dbo.table1.fk_Version
              FOR XML PATH('')), 1, 1, '') AS groupName
FROM   dbo.main_version
       INNER JOIN dbo.[main]
         ON dbo.version.fk_main = dbo.[main].uid
       INNER JOIN dbo.main_schema
         ON dbo.[main].fk_SCHEMA = dbo.main_schema.uid
       INNER JOIN dbo.table1
         ON dbo.version.uid = dbo.table1.fk_Version
WHERE  ( dbo.main_version.active = 1 )

0 个答案:

没有答案