Create one table from another with similar structure and existing data.

Posted by Puneet20884 under Sql Server category on | Views : 2984
Here is a simple statement that can create a similar SQL Table from an existing one without mentioning the column names
or if you mention the column name, the new table with those columns only will be created and data will be populated in the new table as well, here we go :

select * into newtablename from oldtablename

mostly needed for temp tables or tables for testing.

Comments or Responses

Posted by: Puneet20884 on: 1/20/2010 Level:Bronze | Status: [Member]
If no data required, although alternate way is there but you can use following Query then :

select * into as_tblCodesTempCanBeDeleted from aS_tblCodes where 1!=1

Login to post response