Link to home
Create AccountLog in
Avatar of griff77
griff77

asked on

How can I add an index to a view in SQL Server 2005

I currently have a database view in sql server 2005 based on the following query:

SELECT     SUM(Sales) AS SUMSALES, SUM(GrossActualMargin) AS SUMGAM, Date, COUNT_BIG(*) AS Count
FROM         dbo.Fact_Sales
GROUP BY Date

I would like to have an index on the date, but it won't let me because the date field source is nullable.  Any suggestions?  Also,  the view takes about 1 minute to display, as the source table has about 7,000,000 records.  Any suggestions on how to improve the performance is greatly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of x-men
x-men
Flag of Portugal image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of griff77
griff77

ASKER

Database Tuning Advisor helped very much!  Thanks to both of you for your suggestions.