Posts

Showing posts from June, 2021

Table Variable in MS SQL Server

1. Syntax: DECLARE @T TABLE (...) 2. A Table variable is also created on disk in the tempDB system database. But the name of this table variable is generated completely by the SQL engine and it also differs from other similar named tables created in the same or other sessions.                -  check with the below query          select*from tempdb. INFORMATION_SCHEMA.tables 3. A Table Variable is created in memory, this is a myth. They are also treated as Temp-Tables and created in tempdb but they perform slightly better than temp-tables because there is even less locking and logging in a table variable. 4. Table variables are the only way you can use DML statements (INSERT, UPDATE, DELETE) on temporary data within a UDF (User Defined Function). You can create a Table Variable within a UDF, and modify the data using one of the DML Statements, this is not possible with temp-tables.  5. A Table variable ...