10. Dezember 2008 17:47
10. Dezember 2008 22:53
10. Dezember 2008 23:14
11. Dezember 2008 10:42
11. Dezember 2008 14:14
fiddi hat geschrieben:@SilverX
laut MSSQL- Vergleich der Editionen gibt es in 2008 bei der Standard keine indexed Views
CREATE VIEW
[dbo].[TestIndexedView]
WITH SCHEMABINDING AS
SELECT COUNT_BIG(*) "$Cnt", [Item No_], [Location Code], SUM([Sales Amount (Actual)]) AS SalesAmount, SUM([Cost Amount (Actual)]) AS CostAmount
FROM dbo.[CRONUS AG$Value Entry]
GROUP BY [Item No_], [Location Code]
GO
/****** Object: Index [VSIFTIDX] Script Date: 12/11/2008 10:09:57 ******/
CREATE UNIQUE CLUSTERED INDEX [TestIndexedViewIndex] ON [dbo].[TestIndexedView]
(
[Item No_] ASC,
[Location Code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [Data Filegroup 1]
GO
select [Item No_], [Location Code], SUM([Sales Amount (Actual)]) AS SalesAmount, SUM([Cost Amount (Actual)]) AS CostAmount
from dbo.[CRONUS AG$Value Entry]
GROUP BY [Item No_], [Location Code]
order by [Item No_], [Location Code]
go
select * from TestIndexedView
order by [Item No_], [Location Code]
12. Dezember 2008 00:28
12. Dezember 2008 09:05
12. Dezember 2008 10:16
select * from TestIndexedView with(NOEXPAND)
order by [Item No_], [Location Code]
ValueEntry.SETCURRENTKEY("Item No.","Valuation Date","Location Code","Variant Code");
ValueEntry.SETRANGE("Item No.", '1100');
ValueEntry.CALCSUMS("Cost Amount (Actual)");
Daraus wird unter anderem folgende Cursorvorbereitung:
declare @p1 int
set @p1=97
exec sp_prepexec @p1 output,N'@P1 varchar(20)',N'SELECT SUM("SUM$Cost Amount (Actual)") FROM dbo."CRONUS AG$Value Entry$VSIFT$6" WITH (READUNCOMMITTED, NOEXPAND ) WHERE (("Item No_"=@P1))','1100'
select @p1
12. Dezember 2008 11:40
12. Dezember 2008 12:51
14. Dezember 2008 02:34