SELECT INTO Statement:
SELECT INTO statement is used to copy data from one table into another table. We can provide a condition while using SELECT INTO statement.
Syntax:
SELECT columnname(s)
INTO new_tablename
FROM tablename
WHERE EXISTS
(SELECT columnname
FROM tablename
WHERE condition);
Example:
SELECT * INTO EMP
FROM Employee
WHERE City = 'Delhi';
The above query will copy those employee records from Employee table into EMP table who belong to Delhi.
Example for copying only selected columns:
SELECT EmpName, Address
INTO EMP
FROM EMPLOYEE;
This query copy only Employee Name and their addresses into EMP table;
0 Comment(s)