Wednesday, January 25, 2012

Insert multiple rows using a single INSERT statement

The common thing That all have you done using Insert command is to insert the data into data base table .But the thing here is "can we store the data into multiple tables using single Insert command?".we can say surely "it can possible ". Recently i had a requirement to store the data into different tables using single INSERT query.Here i will show how to insert the data into multiple table using single select statement in sql

Example:
INSERT ALL
  INTO employee(empid, empname) VALUES (1, 'Developer')
  INTO Departments (Deptid, Deptname, category) VALUES (15, 'Information 
Technology', 'Computers')

 SELECT * FROM dual;
The above query will insert one row into the employee table and one row into the
Departments table.
Post a Comment

Bel