我想指數這種看法,因爲它有子查詢我不能索引。任何人都可以建議如何改變這個觀點,以便我可以索引它。我該如何改變這種觀點?
ALTER VIEW [dbo].[Recon2]
WITH SCHEMABINDING
AS
SELECT
dbo.Transactions.CustomerCode,
dbo.Customer_Master.CustomerName,
dbo.Transactions.TransDate,
dbo.Transactions.PubCode,
dbo.Transactions.TransType,
dbo.Transactions.Copies,
SUM(dbo.Transactions.TotalAmount) AS TotalAmount,
'0' AS ReceiptNo,
'2008-01-01' AS PaymentDate,
0 AS Amount,
dbo.Transactions.Period,
dbo.Transactions.Year,
dbo.Publication_Master.PubName,
dbo.Customer_Master.SalesCode,
COUNT_BIG(*) AS COUNT
FROM
dbo.Publication_Master INNER JOIN
dbo.Customer_Master INNER JOIN
dbo.Transactions ON dbo.Customer_Master.CustomerCode = dbo.Transactions.CustomerCode ON
dbo.Publication_Master.PubCode = dbo.Transactions.PubCode
WHERE
(dbo.Customer_Master.CustomerCode NOT IN
(SELECT CustomerCode
FROM dbo.StreetSaleRcpt
WHERE (PubCode = dbo.Transactions.PubCode) AND
(TransactionDate = dbo.Transactions.TransDate) AND
(Updated = 1) AND
(PeriodMonth = dbo.Transactions.Period) AND
(PeriodYear = dbo.Transactions.Year)))
GROUP BY dbo.Transactions.CustomerCode, dbo.Customer_Master.CustomerName, dbo.Transactions.TransDate, dbo.Transactions.PubCode,
dbo.Publication_Master.PubName, dbo.Customer_Master.SalesCode, dbo.Transactions.[Update], dbo.Transactions.TransType,
dbo.Transactions.Copies, dbo.Transactions.Period, dbo.Transactions.Year, dbo.Transactions.TotalAmount
我使用SQL 2005和IAM設計爲每月核對報告視圖。這僅僅是一個查詢的一部分和IAM有工會加入其他parts..it返回1MB。 – jbcedge 2008-09-24 22:28:17