Thursday, May 23, 2013

How we will Copy data from one table to another table

Syntax :: select * into <NewTableName> from <OldTablename>

Example:: Suppose tbEmployee is one table we want to copy the whole table to tbEmployeeInformation table, so do the below process
select * into tbEmployeeInformation  from tbEmployee

If we want to copy only schema of the table but not data of the table mean do the  below process
Syntax:: select * into <NewTableName> from <OldTableName> where 1=2

NOTE:: Only Schema and date will be copied, The constraints(Primary key,Foreign Key...) willn't be copied into new table.

No comments:

Post a Comment