CTAS syntax for creating tables in SQL Server

Create structure, duplicate & backup of the table in SQL Server

Use of CTAS for creating the Duplicate table with data or only structure (by using where 1 = 0) in the database as follows:

Use CTAS syntax to create a table with same structure:

-- Create only structure of table
select * into backup_table from employees where 1=0;

Copy the table or take backup of table with data in SQL:

-- Create structure with completed data
Select * into backup_employee from employees;

Leave a Reply