Table variable & temptable

  • What is the difference b/n table variable & temp table. Is it possible to create clustered index on table variable. If yes how many we can create. I read that we can't create non-clustered index on table variable.

  • Search the articles on this site, there are a couple of good articles on exactly that topic.

    Yes, you can have a clustered index on a table variable, yes you can have nonclustered indexes on table variables.

    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
  • Thank you. I got it so with table variable definition, we can create indexes but later we can't add indexes. But is there any limit for the no. of indexs

  • ramana3327 (12/28/2013)


    But is there any limit for the no. of indexs

    Yes, same as for any other table.

    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

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply