How to create a table structure in SQL without using the create command

advertisements

How to Create a table structure in SQL without using the create command

in SQL Server and Oracle DB


One way to do in TSQL for Temp tables is:

Say you have a TableA and TableB and you want to create a table(structure) with some columns from TableA and some from TableB without creating a permanent table then you can write as:

Select T1.ColA,T2.ColB
into #Temp -- only skeleton will be created
from TableA T1
join TableB T2 on T1.SomeCol= T2.Somecol
where T1.ColA = -1 -- some condition which can never be true