Temporary Tables

1. Temporary Tables are similar to tables unlike they are life is only for the current session and it will be automatically dropped after that.
2. This is very useful for storing some information during a large computations temporarily instead of using physical tables.
3. They cannot have foreign key constraints.
4. It is stored in the TempDB.
5. The Syntax is
CREATE TABLE #< TableName >(< ColumnName1 > < Datatype >,< ColumnName2 > < Datatype >…)
6. The below shows an example how to create a temporary table
CREATE TABLE #tempEmployees(EmployeeID int PRIMARY KEY,
FirstName varchar(50),
LastName varchar(50),
Sex char(1),
Age int CONSTRAINT df DEFAULT 18,
DateOfBirth DateTime)

Comments

Popular posts from this blog

“Unable to retrieve the metadata for …” Error while using ASP.NET MVC 3

Getting Started with ASP.NET MVC, SignalR KnockoutJS

Visual Studio 2013 and .NET 4.5.1