我的計算列在我的視圖中有問題。創建索引視圖時出錯
SELECT ColumnC, ColumnA % ColumnB AS ModuloColAColB, COUNT_BIG(*) AS cBig FROM dbo.T1
GROUP BY ColumnC, ModuloColAColB
查詢與此類似MSDN例如: http://msdn.microsoft.com/en-us/library/ms191432.aspx
當我嘗試編譯視圖我收到錯誤信息,如: 「無效列名ModuloColAColB」
所以我用柱更改組名稱:
SELECT ColumnC, ColumnA % ColumnB AS ModuloColAColB,
COUNT_BIG(*) AS cBig FROM dbo.T1
GROUP BY ColumnC, ColumnA, ColumnB
視圖編譯正確,但當我嘗試添加索引我收到錯誤:
"Cannot create the clustered index 'px_test' on view 'l' because the select list of the view contains an expression on result of aggregate function or grouping column.
Consider removing expression on result of aggregate function or grouping column from select list"
當我刪除「ColumnA%ColumnB AS ModuloColAColB」一切正常。
數據庫版本:SQL Server 2005企業版。
在簡單的重複,當你使用 GROUP BY ColumnC會發生什麼,ColumnA%ColumnB – 2009-12-04 12:04:52
的觀點是正確的編譯,但不能創建索引 – itdebeloper 2009-12-07 21:42:13