INSERT INTO SELECT and SELECT INTO Statements
We can insert data from one table to other table using below two statements.- INSERT INTO SELECT Statement: This Statement will work if the table is exists. we will insert data from one table to other table. For using statement table should be created previously. Before going to run below script, Please create this tables.
create table Employee(eno int, ename varchar(30)) insert into Employee(eno, ename) select eno,ename from employeeMaster select * from Employee drop table employee
- SELECT INTO: We no need to create a table. Table will create automatically and send data from one table to other.
select eno, ename into Employee from employeemaster select * from employee drop table employee
Output of the above statements:
Most of the times we will use this concept with SQL Temp Table in stored procedures and functions.
This is one of the good SQL Server Interview Questions.
Most of the times we will use this concept with SQL Temp Table in stored procedures and functions.
This is one of the good SQL Server Interview Questions.
Post a Comment
Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.