Thursday, 30 May 2013

Different Ways to use Insert Command in Sqlserver




--Simple Insert Command

Insert into Employee values('1','Rajesh');
Insert into Employee values('2','Harish');

--Insert command using Column name which specifies in which column we are going to insert  the data

Insert into Employee (emp_id,emp_name)values('3','lokesh');
Insert into Employee (emp_id,emp_name)values('4','siva');

--Insert command in which we select records from another table

Insert Employee1 select * from Employee;
Insert into Employee1 select * from Employee;

--Insert miltiple records in single Insert Command

Insert into Employee (emp_id,emp_name)
select  1,'Rajesh'
union all
select  2,'Harish';

Insert into Employee (emp_id,emp_name)values
('3','lokesh'),
('4','siva');

No comments:

Post a Comment