2011/02/24

Simple Lesson : Copy some or all fields value, from a table into new table

You can create backup table for all fields or some fields with SQL Query.
This Query very useful for backup table without a lot of code.But there is rule you must follow,destination table must new table,not same with another table in database.

Syntax Code :

SELECT [fields] INTO [destination table] FROM [source table] where [condition]

SELECT [fields] INTO [destination table] IN [database file] FROM [source table] where [condition]

Consider the following example:

1. If you wan copy all fields form a table to another table
SELECT * INTO EmployeeBackup FROM Employee where status= 'Manager'

2. If you want copy some fields from a table to another table
SELECT Name,Contract INTO EmployeeBackup FROM Employee where status= 'Manager'

3. If you want copy fields to another database
SELECT * INTO EmployeeBackup IN 'backup.MDB' FROM Employee where status= 'Manager'

No comments:

Post a Comment

Your Comment