Tuesday 24 August 2021

SQL insert query

 Hi guys, in this blog post we will see how to insert data into SQL table. This blog post is for SQL beginners. Let's see it practically.

SQL insert statement is used to insert new row in SQL table.

Syntax for SQL Insert Query:-

INSERT INTO [TableName]

           (columnName1

           ,columnName2

           ,columnName3

           ,columnName4)

     VALUES

           (columnValue1

           ,columnValue2

           ,columnValue3

           ,columnValue4)

GO 

For e.g. We have table tblEmployee. We want to insert data into following table.

SQL insert query

Following SQL query is used to insert data into SQL table tblEmployee. Type the following query in query window and execute the query.

SQL Insert Query:-

INSERT INTO tblEmployee

           (EmployeeFirstName

           ,EmployeeLastName

           ,CreatedDate

           ,ModifiedDate)

     VALUES

           ('Sam'

           ,'Sharma'

           ,CURRENT_TIMESTAMP

           ,CURRENT_TIMESTAMP)

GO

SQL insert query

After executing above query data in table will look like:-

SQL insert query

For retrieving data from table, you can use following select query:-

SELECT * FROM tblEmployee


No comments:

Post a Comment