I want to create indexed view with such 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))
I need to make group by only by datepart of column Object_CreationDate
(type datetime2 ).
Also I want to set index on columns Theme_Id
AND Object_CreationDate
in the derived view.
If I use cast(CONVERT(varchar(8), m.Mention_CreationDate, 112)AS DateTime)
in SELECT - I'll get problems with index on this column. Because this column (Object_CreationDate
) is not deterministic.
I wonder if it is possible to solve a problem.