SQL Insert Into Command

SQL Insert IntoCommand

How to Copying a Table Definition
Use the CREATE TABLE command with a subquery that returns no rows:
Query:
Create Table E_Detail as Select * from Employees where 1>2
Insert Data from One table into another
Suppose you want to insert rows from one table to another by using a query. The query may be complex or simple. This query performs conditionally insertion or specifies column conditions.

Insert into e_detail(Employee_ID,First_Name,Salary)
select Employee_ID,First_Name,Salary
from Employees
where Department_ID in (60,90)
Result
Select Employee_ID,First_Name,Salary From E_Detail
 
Suppose you want to insert rows from one table to another without conditionally insertion.

Insert into e_detail

select *

from Employees

Leave a Reply

Your email address will not be published. Required fields are marked *