Visual Studio Tableadapter SQL语句错误“无法解析查询文本”

时间:2019-04-24 13:40:47

标签: sql visual-studio tableadapter

此代码在SQL Server中正常工作。但是Visual Studio中的tableadapter向导显示错误:

  

生成的SELECT语句
  无法解析查询文本

代码:

SELECT 
    COUNT(NULLIF(bcg,'')) AS [babycount], 
    'BCG' as [Vaccines], 
    DATENAME(month, date)[Month], 
    year(GETDATE())[year] 
FROM 
    IMMUNI 
GROUP BY
    DATENAME(month, date)

UNION ALL

SELECT 
    COUNT(NULLIF(hepab, '')) AS [babycount], 
    'Hepa B' AS [Vaccines], 
    DATENAME(month, date) [Month], 
    year(GETDATE()) [year] 
FROM 
    IMMUNI 
GROUP BY
    DATENAME(month, date)

UNION ALL

SELECT 
    COUNT(NULLIF(pentaone, '')) AS [babycount], 
    'Penta One' AS [Vaccines], 
    DATENAME(month, date) [Month], 
    year(GETDATE()) [year] 
FROM 
    IMMUNI 
GROUP BY
    DATENAME(month, date)

任何帮助将不胜感激。

0 个答案:

没有答案