Hi,
Tables can be created dynamically in following ways.
1. Dynamic SQL -- 'Need to construct query to create table'.
Note :- here you have to check whether the table is already there
or not before executing the Dynamic sql query.
2. SELECT statement
Here we have two options to create table.
a)Create table along with data
SELECT A.COL1,A.COL2... INTO NEWTABLE
FROM EXISTINGTABLE
If you execute this query ... sql server not only creates a table
according to the SELECT criteria but also inserts the result set
of the query into the newly created table.
b)Create table with schema only
SELECT A.COL1,A.COL2... INTO NEWTABLE
FROM EXISTINGTABLE WHERE 1=0
This query creates table according to the SELECT criteria. Here
data will not be stored in newly created table.
Thank you