articles

Home / DeveloperSection / Articles / how to copy data and structure from a table in sql server

how to copy data and structure from a table in sql server

Anonymous User 1439 12-Jul-2018

Introduction:

In this article we are going to how to copy an existing table to new table in SQL Server with an example.

Description:

The SQL Server (Transact-SQL) SELECT INTO statement is used to create a new table from an existing table by copying the existing table's schema and data. It is important to note that when creating a table in this way, the new table will be populated with the records from the existing table (based on the SELECT Statement).

Let’s see simple an example of SELECT INTO statement

CUSTOMER TABLE

how to copy data and structure from a table in sql server

SELECT INTO statement

SELECT * INTO NEW_CUSTOMER from CUSTOMER

NEW_CUSTOMER TABLE 

how to copy data and structure from a table in sql server

In above example, we have a customer table, which is copied customer table data and schema to the new Customer table. 

I hope it will help you after reading it.

you might also like to read next topic how to import excel data in sql server database use Cursor in SQL serversubquery in sql with example ,  how to create Table-valued functions in SQL




Updated 07-Sep-2019
I am a content writter !

Leave Comment

Comments

Liked By