Wednesday, March 18, 2009

Bulk inserting values from one table to another table

There may be situations when you need to copy records from one table to another on a specific condition. This is can be achieved by simply using the insert and select combination in your sql query. For example the following query copies the names of employees(emp table) who are managers(Manager table).

insert into Manager(name) select name from emp where designation ='mngr' .

NB:The number of fields you are selecting must be equal with the inserting fields.

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails