Posts Tagged ‘backup’

Create backup copy of table in SQLServer – (Select Into)

SELECT INTO statement can be used to create backup copy of a table.This sql statement selects records from one table according to the selection we make and inserts the result set into another new table with the table name we specify.

Syntax given below is used to make a exact copy of the table.That is it creates the table with the same no of columns and all records in the old table.

Syntax : Exact copy of old table

SELECT *
INTO new_table_name
FROM old_table_name

Example :

select * into employee_backup from employee

In this example a exact copy of the table employee is backed up as a new table employee_backup.

Syntax given below is used to make a new table with selected columns from old table.

Syntax : Selected columns from old table

SELECT column_name(s)
INTO new_table_name
FROM old_table_name

Example :

select employee_id,employee_name into employee_backup from employee

In this example a copy of the table employee with only columns “employee_id,employee_name” is backed up as a new table employee_backup.

Popularity: 9% [?]

Designed by: Business Web Hosting | Thanks to Buy Icons, travel tips and Used Cars