Home Forums SQL Server 2008 T-SQL (SS2K8) how to create COMPUTED columns inSQL server 2008 for DATEADD(yy, -1, GETDATE()) RE: how to create COMPUTED columns inSQL server 2008 for DATEADD(yy, -1, GETDATE())

  • kbhanu15 (1/17/2014)


    HI All,

    Can any one help me how to create COMPUTED columns on DATEADD(yy, -1, GETDATE()) ?

    What have you tried so far?

    1. Instead of this DATEADD(yy, -1, GETDATE()) i want to use COMPUTED column to improve the performance,

    Replacing a computation with exactly the same computation done in a different place isn't going to do anything for performance. Why do you think that the DATEADD is a performance problem?

    2. Also create the NON CLUSTERED index on this new computed column.

    Not possible, because it's not a deterministic function. See 'Creating Indexes on Computed Columns' in Books Online

    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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass