【发布时间】:2010-12-10 13:07:51
【问题描述】:
我想用这样的 t-sql 创建索引视图:
Select
Table1_ID,
cast(CONVERT(varchar(8),
t2.Object_CreationDate, 112)AS DateTime) as Object_CreationDate ,
Count_BIG(*) as ObjectTotalCount
from
[dbo].Table2 t2 inner join [dbo].Table1 t1 on ...
Group BY
Table1_ID, CONVERT(varchar(8), t2.Object_CreationDate, 112))
我需要group by 仅按Object_CreationDate 列的datepart (类型 datetime2 )。
我还想在派生视图中为列 Theme_Id 和 Object_CreationDate 设置索引。
如果我在 SELECT 中使用 cast(CONVERT(varchar(8), m.Mention_CreationDate, 112)AS DateTime) - 我会遇到此列的索引问题。因为此列 (Object_CreationDate) 不是确定性的。
不知道有没有可能解决问题。
【问题讨论】:
标签: sql-server view windows-server-2008-r2 indexed