我有一个查询,我在SQL中开发并运行正常,但是当我将查询放入SQL Server(或.Net)查询生成器时,它会生成错误。这里要说的是像我写SQL Server查询生成器错误?
此查询的例子我写什么(工作)
Select Case when Table1.[Col 1] is null then Table2.[Col 1] Else Table1.[Col 1] END as 'col1' From
(Select Sum(Table3.[Col 1]) as 'col 1', Table3.[groupby col] from Table3 Group by Table3.[groupbycol]) as Table1 FULL OUTER JOIN (Select Sum(Table3.[Col 1]) as 'col 1', 'Total' as 'groupby col' from Table3) as Table2 ON Table1.[groupby col] = Table2.[groupby col]
但当时如果我在SQL或asp.net查询生成器打开这个“改进“它使中断查询,现在看起来是这样的
Select
Case
when Table1. 'Col 1' is null
then Table2. 'Col 1'
Else Table1. 'Col 1'
END as 'col1'
From
(Select
Sum(Table3.[Col 1]) as 'col 1',
Table3.[groupby col]
from
Table3
group by
Table3.[groupbycol]) as Table1
FULL OUTER JOIN
(Select
Sum(Table3.[Col 1]) as 'col 1',
'Total' as 'groupby col'
from Table3 as Table3_1) as Table2 ON Table1. 'groupby col' = Table2. 'groupby col'
不再适用,因为它,因为它取代了[]与和列名前添加一个空格和表3创建别名在第二个查询中,然后不会将该别名分配给使用该表的其他时间
任何人都知道是什么原因造成这似乎每次我打开一个查询构建器它可能搞砸查询
感谢
引用标识符 – Jodrell