Insert into Clause in SQL | SQL Beginners | DataGuru Naval

Опубликовано: 14 Февраль 2022
на канале: DataGuru Naval
67
4

Insert into Clause in SQL | SQL Beginners | DataGuru Naval

Using VALUES Keyword
1)
Insert into tblEmp(Empid, EmpName, EmpDesignation)
Values (101,'ABC','Software Developer')

2)
Insert into TableName
Values (102,'XYZ','SQL Developer')

3)
Use Multiple insert with multiple Values
Insert into tblEmp(Empid, EmpName, EmpDesignation)
Values (101,'ABC','Software Developer')

go

Insert into tblEmp(Empid, EmpName, EmpDesignation)
Values (101,'ABC','Software Developer')

go

Insert into tblEmp(Empid, EmpName, EmpDesignation)
Values (101,'ABC','Software Developer')

4. Use single insert with Multiple values

Insert into tblEmp(Empid, EmpName, EmpDesignation)
Values (101,'ABC','Software Developer'),
(102,'XYZ','SQL Developer'),
(103,'LMN','Database Developer'),
(104,'PQR','Database Administration')

5. Using SELECT Statement


Insert into tblEmp(Empid, EmpName, EmpDesignation)
select Empid, EmpName, EmpDesignation
from tblemployee


6. To Create and insert data into Physical table
select *
into testemp
from tblemp

7. To Create and insert data into Temporary table
select *
into #testemp
from tblemp

temporary table exists till the open session exists. Once opened
session is closed, temporary table deleted permanantly.