July 15, 2010 at 7:37 am
I was just wondering if it was possible to build a non-clustered index using things like DATEPART inside of it? Such as:
CREATE NONCLUSTERED INDEX [IX_Dates] ON ##Temp
(
DATEPART(YEAR,UpdatedDate) ASC,
DATEPART(MONTH, UpdatedDate) ASC
)
Owner & Principal SQL Server Consultant
Im Your DBA, Inc.
https://www.imyourdba.com/
July 15, 2010 at 7:52 am
Not like that.
Look up computed columns. If a computed column adheres to a list of requirements, it can be persisted and indexed.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 15, 2010 at 7:58 am
GilaMonster (7/15/2010)
Not like that.Look up computed columns. If a computed column adheres to a list of requirements, it can be persisted and indexed.
Oh I see. You can't use DATEPART in the index creation but I could use a computed column in building the temp table and then index that column. Makes sense.
Thanks!
Owner & Principal SQL Server Consultant
Im Your DBA, Inc.
https://www.imyourdba.com/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply