• DECLARE @tmp_Table table (StudID int Primary key,StudName VARCHAR(2000),Class VARCHAR(50))

    CREATE INDEX Idx1 ON @tmp_table(StudID)

    CREATE table #tmp_Table (StudID int Primary key,StudName VARCHAR(2000),Class VARCHAR(50))

    CREATE INDEX Idx1 ON #tmp_table(Class)

    I execute above code in my Sql2008

    but in case of table variable it shows Error ,

    But we can set Indexes on Table variables at the time of table Definition

    DECLARE @tmp_Table table (StudID int Primary key,StudName VARCHAR(2000),Class VARCHAR(50),

    UNIQUE (Class) )

    [font="Verdana"] There is no Wrong time to do a Right thing 🙂 [/font]