![Share on Facebook Facebook](https://www.sqlserver.info/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/facebook.png)
![Share on Twitter twitter](https://www.sqlserver.info/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/twitter.png)
![Share on Reddit reddit](https://www.sqlserver.info/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/reddit.png)
![Pin it with Pinterest pinterest](https://www.sqlserver.info/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/pinterest.png)
![Share on Linkedin linkedin](https://www.sqlserver.info/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/linkedin.png)
![Share by email mail](https://www.sqlserver.info/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/mail.png)
This is truly an amazing feature to add to SQL Server 2014. I use table variables all the time and this was the only thing I didn’t like about them. Up to this point, SQL Server did not support having non-clustered indexes on table variables (the one with the name that starts with the @). If you wanted to do this, you had to create/use a temp table (the one with the name that starts with #).
With SQL Server 2014, they changed this and now allow the table variables to have non-clustered indexes as well. To do this, we simply add a little bit of extra code after the column declaration.
DECLARE @AnimalTableVar TABLE ( AnimalID INT, AnimalName VARCHAR(50) INDEX IX_AnimalTempTable_AnimalName )
In the sample above, we create a table variable called @AnimalTableVar. Then when we declare the column AnimalName, we add an index called IX_AnimalTempTable_AnimalName.
Here is how selecting from this table shows up in the execution plan!
Reference: http://msdn.microsoft.com/en-us/library/ms188927(v=sql.120).aspx