DataSet TableAdapter抛出OVER SQL构造或语句不受支持

时间:2010-06-29 07:35:42

标签: visual-studio-2008 tsql

我有一个用this sample help编写的t-sql查询。

SELECT  t.gName AS 'Product'
, isnull(SUM(CASE WHEN t.Col = 1 THEN t.Quantity END),0) AS '180ml'
, isnull(SUM(CASE WHEN t.Col = 2 THEN t.Quantity END),0) AS '375ml'
, isnull(SUM(CASE WHEN t.Col = 3 THEN t.Quantity END),0) AS '500ml'
, isnull(SUM(CASE WHEN t.Col = 4 THEN t.Quantity END),0) AS '1000ml'
, isnull(SUM(CASE WHEN t.Col = 5 THEN t.Quantity END),0) AS '2000ml'
FROM (
SELECT p.pName
     , p.pCode
     , p.pGroup
     , p.pSize, i.gName, i.gCode
     , sl.Quantity, sl.BillDate
     , DENSE_RANK() OVER(PARTITION BY p.pGroup ORDER BY p.pSize) AS Col 
    FROM 
        ItemGroup AS i INNER JOIN 
                          Products AS p ON i.gCode = p.pGroup INNER JOIN 
                          SalesLog AS sl ON p.pGroup = sl.pGroup
       AND p.pCode = sl.ProductCode   
       ) AS t where t.BillDate=@BillDate and t.pGroup!=15 and t.pGroup!=16
     GROUP BY t.gName
    order by t.gName

它在Management Studio查询编辑器中工作但不在DataSet中抛出错误,例如 OVER SQL构造或语句不受支持。

这是Report(.rdlc)所需的查询。请帮忙

谢谢

2 个答案:

答案 0 :(得分:5)

我会将此SQL放入存储过程或视图中。然后,您可以从那里填充DataSet。

答案 1 :(得分:0)

ADAPTER无法为脚本创建图表。右键单击,转到窗格,分析图表......就是这样!它运行:))