Indexes or other constraints applied to the table data type must be defined as part of the DECLARE variable or CREATE FUNCTION statement. They cannot be applied later, because the CREATE INDEX or ALTER TABLE statements cannot reference table variables and user-defined functions. Check 'DECLARE @local_variable' in books online.