Table Variables

Temp variable can be created like this:

DECLARE @temp_tblEmployee TABLE 
(
	[Emp_ID] [int] NOT NULL,
	[Emp_Name] [varchar](max) NOT NULL
)
INSERT INTO @temp_tblEmployee
SELECT 1,'Shashangka Shekhar'

SELECT * FROM @temp_tblEmployee

GO

Table variable is always useful for less data. If the result set returns a large number of records, we need to go for temp table.

Author:

Since March 2011, have 8+ years of professional experience on software development, currently working as Senior Software Engineer at s3 Innovate Pte Ltd.

Leave a Reply

Your email address will not be published.