I don't see ValidTo in the table definition. However, you might want to read the section in the Ref Manual Building Blocks on Table Variables. I remember reading that constraints are not allowed (except null)....and I am pretty sure indexes are not as well. If the @table_var is going to contain so much data that you would want an index, you should use a #temp table. @table_vars come out of proc cache - and if there is not enough proc cache, they will spill to disk anyhow....with #temps for large working sets, you get the advantage of lazy IOs in tempdb.
↧