I have a datetime field in a table called dbo.Traffic
I am trying to aggregate traffic data by day. I am planing on creating a schemabound view and adding an index.
CREATE VIEW [dbo].[vwTraffic] WITH SCHEMABINDING AS
SELECT CONVERT(date, CreateDate) as CreateDate, Circuit, Fuseaction,
COUNT(CreateDate) AS activity
FROM dbo.Traffic WITH (NOLOCK)
GROUP BY CONVERT(date, CreateDate), Circuit, Fuseaction
In the base table, CreateDate is not nullable. However, as soon as I create a view and convert it to a date, it becomes nullable.