We created an indexed view by such sql:
Select Table1_ID, Count_BIG(*) as Table2TotalCount from Table2 inner join
Table1 inner join... where...
Also after creating the view, we set clustered unique index on column Table1_ID.
So View consists of two columns:
Table1_ID
Table2TotalCount
We have two questions:
- If we use
Count(1)
orCount_BIG(1)
instead ofCount_BIG(*)
, SQL doesn't allow us to set index on Table1_ID - How can we control the type of second column (
Table2TotalCount
) - SQL give a long nullable type to this column. But we want to set int not nullable type to this column. After creating View, we can't find any way to change column type. Also t-sql we use for creating view, always return int values to Table2TotalCount.