Index on field length

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • balabaster
    Recognized Expert Contributor
    • Mar 2007
    • 798

    Index on field length

    Does anyone know if it's possible to create an index based on the length of a field in a table?
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    try to create function based index.

    Comment

    • balabaster
      Recognized Expert Contributor
      • Mar 2007
      • 798

      #3
      Originally posted by debasisdas
      try to create function based index.
      Is that possible in SQL Server? I couldn't find a way to make it work. In the end, I created some extra calculated fields and indexed those.

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        Originally posted by balabaster
        Is that possible in SQL Server? I couldn't find a way to make it work. In the end, I created some extra calculated fields and indexed those.
        since sql server does not suppor that type of index you need to use some workaround to create an extra field and index that . you can always populate that field using some trigger.

        Comment

        • balabaster
          Recognized Expert Contributor
          • Mar 2007
          • 798

          #5
          Originally posted by debasisdas
          since sql server does not suppor that type of index you need to use some workaround to create an extra field and index that . you can always populate that field using some trigger.
          The fields I created are actually calculated, which I suppose in some sense work like a trigger... I may change them so they're updated by a trigger instead of being calculated which theoretically could improve query performance for selects as the calculation wouldn't need to be performed on each row as they are queried.

          Comment

          Working...