Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create clone copy of table without data in SQL Server

Tags:

sql

sql-server

How can I create clone copy of table without data? Because I just want to copy a definition of table not data.

I tried below but it is copying data as well

Select * 
into Clone_Supplier  
from Supplier
like image 652
Sql Learner Avatar asked Dec 03 '17 09:12

Sql Learner


2 Answers

Copy all columns from selected table

Select Top 0 * into NewTable from OldTable

Copy some columns from selected table

Select Top 0 Col1,Col2 into NewTable from OldTable

Copy all(Data and Structure)

Select * into NewTable from OldTable
like image 111
nazmul.3026 Avatar answered Oct 20 '22 05:10

nazmul.3026


It is useful table to generate and new table

 Select Top 0 * into tblNew from tblOld
like image 22
K M ALIM UDDIN Avatar answered Oct 20 '22 06:10

K M ALIM UDDIN