SQL Server Tutorial
INSERT Statement is used to insert rows in the database table.
INSERT [INTO]{table_name} [(column1, column2, ...)] VALUES {DEFAULT | (value1, value2, ...) | SELECT Statement
INTO is optional keyword.
table_name is the name of the database table into which data is to be inserted.
column names are optional parameter which can be used when inserting partial data for rows.
DEFAULT is the clause that can be used to insert the default value is specified for the column.
Value list is the values for the table columns that have to be inserted as a row in the table.
SELECT Statement can be used to insert a row(s) into the table. SELECT Statement can be nested here.
INSERT Department VALUES (1, 'Department1', 'head1')
INSERT Department (Id, Name, Head) VALUES (2, 'Department2', 'head2')Insert a row into the Department table with columns sequence and the column values in the INSERT and VALUES clause respectively.
INSERT Department (Name, Head, Id) VALUES ('Department3', 'head3', 3)Insert a row into the Department table with columns name specified with specifying NULL or DEFAULT value.
INSERT Department (Id, Name, Head) VALUES (4, 'Department4', NULL)
INSERT Department (Id, Name, Head) VALUES (5, 'Department5', DEFAULT)
INSERT Department (Id, Name) VALUES (5, 'Department5')here Head column is not specified because which can be NULL.
INSERT Employee (Name, DeptId, Email) VALUES ('Employee2', 2, 'employee2@test.com')
INSERT INTO Employee (Name, DeptId, Email, Salary, City, Country) VALUES ('Employee1', 1, 'employee1@test.com', 8000, 'BOSTAN', 'US')
INSERT INTO Employee (Name, DeptId, Email, Salary, City, Country) VALUES ('Employee2', 1, 'employee2@test.com', 5000, 'NEYWORK', 'US')
INSERT INTO Employee (Name, DeptId, Email, Salary, City, Country) VALUES ('Employee3', 2, 'employee3@test.com', 9000, 'CHENNAI', 'INDIA')
INSERT INTO Employee (Name, DeptId, Email, Salary, City, Country) VALUES ('Employee4', 1, 'employee4@test.com', 6000, 'BANGALORE', 'INDIA')
SQL Server Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page