| Madhivanan's TSQL Blog |
Did you know that table variables are stored in the tempdb database for execution scope only?. Ok. Let us run this code
declare @t table(i int)
select * from tempdb.INFORMATION_SCHEMA.TABLES
The result is
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
---------------------------------------------------------------------
tempdb dbo #BAB3F665 BASE TABLE
If your server does not use any temporary tables, you will get the above
result only. As you see a table variable is stored in the tempdb database for the execution scope only just like a temporary table. The name is prefixed by #. But unlike a temporary table, the name does not contain underscores. Becauase they are stored in execution scope only, you cannot query the INFORMATION_SCHEMA.TABLES alone to get the table variable information. The following code will not show you any table vaiables
select * from tempdb.INFORMATION_SCHEMA.TABLES
How many of you know this?...(Read whole news on source site)




