-- create Local temporary table i.e single hash(#)
CREATE TABLE #TempTable
( Column1 datatype, column2 datatype……)
INSERT INTO #TempTable
(Column1, column2……)
VALUES ('value 1', 'value 2')
-- 2nd method (Select Into)
SELECT * INTO #TempTable
FROM SampleTable
WHERE...
-- create Global temporary table i.e double hash(##)
CREATE TABLE ##tablename
( Column1 datatype, column2 datatype……)
-- CREATE TEMP TABLE
Create Table #MyTempTable (
EmployeeID int
);
DECLARE @TempTable AS TABLE(//Mention your columns in here.//)
After that you can insert into this table later.
DECLARE @TempTable AS TABLE (Id INT); -- add column that you need with datatype.
IF Object_ID('tempdb..#Tablename') IS NOT NULL DROP TABLE #Tablename
Select
*
into
#Tablename
FROM
SampleTable
If(OBJECT_ID('tempdb..#temp') Is Not Null)
Begin
Drop Table #Temp
End
Code Example |
---|
Sql :: mysql command prompt date insert format |
Sql :: initcap in sql |
Sql :: sql where not like in list |
Sql :: sql pivot |
Sql :: mysql where in maintain order group_concat |
Sql :: sql join on a subquery |
Sql :: android sqlite query join |
Sql :: sqlite unix timestamp |
Sql :: mysql two joins |
Sql :: decimal() mysql |
Sql :: joins in sql |
Sql :: sql composite key |
Sql :: to show sp in sql server |
Sql :: mysql create table if not exists |
Sql :: how to use query in nosql |
Sql :: sql unique |
Sql :: like query |
Sql :: postgres full text search example |
Sql :: wamp server mysql password |
Sql :: insert or update sql query |
Sql :: postgresql having |
Sql :: sql trying to delete database in use |
Sql :: openquery join two tables |
Sql :: date datatype in livesql |
Sql :: many to many flask-sqlalchemy |
Sql :: limit and offset in stored procedure mssql |
Sql :: oracle create or replace index |
Sql :: pl sql if boolean |
Sql :: acual month sql |
Sql :: how to find columns with null values in sql |