0

Different methods of SQL queries to insert data in tables

create table EmpDtl1(EmpId int,EmpName varchar(30)) insert into EmpDtl1(EmpId,EmpName) values( 1,'David') insert into EmpDtl1(EmpId,EmpName) values( 2,'Steve') insert into EmpDtl1(EmpId,EmpName) values( 3,'Chris')

13th Dec 2016, 12:15 PM
Akwin Lopez
Akwin Lopez - avatar
5 Answers
0
Insert query result set into table insert into EmpDtl2 select * from EmpDtl1
13th Dec 2016, 12:15 PM
Akwin Lopez
Akwin Lopez - avatar
0
Insert query result set into table create table EmpDtl2(EmpId int,EmpName varchar(30)) insert into EmpDtl2 select * from EmpDtl1
13th Dec 2016, 12:16 PM
Akwin Lopez
Akwin Lopez - avatar
0
We can specify particular columns to insert data as shown below. insert into EmpDtl2 (EmpName) select EmpName from EmpDtl1
13th Dec 2016, 12:16 PM
Akwin Lopez
Akwin Lopez - avatar
0
Insert query result into new table select * into EmpCopy from EmpDtl1
13th Dec 2016, 12:16 PM
Akwin Lopez
Akwin Lopez - avatar
0
Insert rows into table returned by a stored procedure create procedure spGetEmpDetails as begin select * from EmpDtl1 end Below query will insert data into table "EmpDtl1" returned by executing procedure. insert into EmpDtl1 exec spGetEmpDetails
13th Dec 2016, 12:18 PM
Akwin Lopez
Akwin Lopez - avatar