Insert Command in SQL SERVER
Insert command is used to insert data into SQL Server table. You can use the ‘insert command‘ to insert data directly into a table using a T-SQL query or you can use the insert command in CLR or send this command via some other applications.
Insert Command Syntax
Insert into <Table Name>
(columns)
(values)
Example 1: Insert into Command in T-SQL
INSERT INTO Employee_Department
VALUES(10022,'A Smith','Daily Wages',1004,'IT')
In the above code, we have not mentioned the column names. Here we have mentioned values for all columns therefore the column names are not important. Whenever you wanted to enter values for specific columns then you will have to mention the column names also.
Inserting multiple rows into the table
INSERT INTO Employee_Department
VALUES(10022,'A Smith','Daily Wages',1004,'IT')
GO
INSERT INTO Employee_Department
VALUES(10030,'L Jones','Permanet',023,'Pensions')
GO
INSERT INTO Employee_Department
VALUES(21010,'P Lewis','Part Time',004,'IT')
GO
INSERT INTO Employee_Department
VALUES(10010,'B Jones','Trainee',004,'IT')
GO
INSERT INTO Employee_Department
VALUES(10001,'A Smith','Non-Permanent',004,'IT' )
GO
INSERT INTO Employee_Department
VALUES(31002,'T Gilbert','Hourly Wages',028,'Database' )
GO
INSERT INTO Employee_Department
VALUES(13210,'W Richards','Waily Wages',008,'Salary')
GO
INSERT INTO Employee_Department
VALUES(31003,'T Gilbert','Permanet',028,'Database' )
GO
INSERT INTO Employee_Department
VALUES(21023,'P Lewis','Permanent',004,'IT' )
GO
INSERT INTO Employee_Department
VALUES(10034,'B James','Traninee',009,'HR' )
GO
Output:

Example 2: Insert Command into Specific Columns
INSERT INTO Employee(Employee_No,Department_No,Employee_Name,Employee_Type)
VALUES(10022,004,'A Smith','Daily Wages')
GO
INSERT INTO Employee(Employee_No,Department_No,Employee_Name,Employee_Type)
VALUES(10030,023,'L Jones','Permanet')
GO
INSERT INTO Employee(Employee_No,Department_No,Employee_Name,Employee_Type)
VALUES(21010,004,'P Lewis','Part Time')
GO
INSERT INTO Employee(Employee_No,Department_No,Employee_Name,Employee_Type)
VALUES(10010,004,'B Jones','Trainee')
GO
INSERT INTO Employee(Employee_No,Department_No,Employee_Name,Employee_Type)
VALUES(10001,004,'A Smith','Non-Permanent')
GO
INSERT INTO Employee(Employee_No,Department_No,Employee_Name,Employee_Type)
VALUES(31002,028,'T Gilbert','Hourly Wages' )
GO
INSERT INTO Employee(Employee_No,Department_No,Employee_Name,Employee_Type)
VALUES(13210,008,'W Richards','Waily Wages' )
GO
INSERT INTO Employee(Employee_No,Department_No,Employee_Name,Employee_Type)
VALUES(31003,028,'T Gilbert','Permanet' )
GO
INSERT INTO Employee(Employee_No,Department_No,Employee_Name,Employee_Type)
VALUES(21023,004,'P Lewis','Permanent' )
GO
INSERT INTO Employee(Employee_No,Department_No,Employee_Name,Employee_Type)
VALUES(10034,009,'B James','Traninee' )
GO
In the above example, we have neglected the column ManagerID
Output:

Support us by sharing this post