我在使用自定義CLR聚合函數的視圖上創建索引時遇到問題。SQL Server 2008:自定義聚合函數和索引視圖
我看不出任何方法來標記聚合函數確定性或與模式綁定。
我創建我的功能,像這樣:
CREATE ASSEMBLY StringUtil
AUTHORIZATION dbo
FROM 'C:\StringUtil.dll'
WITH PERMISSION_SET = UNSAFE
GO
CREATE AGGREGATE SUMSTRING (@input nvarchar(200))
RETURNS nvarchar(max) WITH SCHEMABINDING
EXTERNAL NAME StringUtil.Concatenate
而我的觀點被定義爲:
CREATE VIEW RolledValues WITH SCHEMABINDING
AS
SELECT ID, SumString(ValueText) as Value FROM [dbo].[IDValue]
GROUP BY ID
當我嘗試上創建視圖索引出現該問題:
CREATE UNIQUE CLUSTERED INDEX IDX_RollValues_ID_VALUE on RolledValues (ID)
Error: Cannot create index on view "dbo.RolledValues" because it uses aggregate
"dbo.SumString". Consider eliminating the aggregate, not indexing the view, or
using alternate aggregates.
那麼有可能在索引視圖中使用自定義聚合函數嗎?我無法找到任何這資料...