How to Work with Temporary Table in Transact-SQL
In this article I am going to explain about how to work with temporary table in Transact-SQL.
Introduction
Transact-SQL (T-SQL) is Structured Query Language and it is Microsoft's and Sybase's proprietary. Transact-SQL is originally developed by IBM for querying, altering and defining relational database. Transact SQL is also known as T-SQL. T-SQL supports many feature like variables, loops, conditions and exceptions.
Temporary Table
Temporary table exists only during the current database session. Tempdb in system database is used to store temporary database. There are two type of temporary table
- Global temporary table
- Local temporary table
The name of local temporary table start with sign # and name of global temporary table start with sign ##.
Example
SELECT TOP 1 vendorid,SUM(invoicetotal)
AS inv_sum
INTO #ven_info
FROM dbo.mcninvoices
GROUP BY vendorid
ORDER BY inv_sum DESC
|