Using SQL to Insert a Row into a Database Table

A good way of inserting a new row into a database table is to use a SQL (Structured Query Language) query. To execute SQL queries you will need to use the SQL query editor of your chosen database. For SQL server, use the Management studio to create a new query by right clicking on the database and selecting “New Query”.

To insert a new row, the table name must firstly be specified and then the column names for which the values are to be inserted into. The values section always comes after the table and column specification and must be in the same order as the column names.

If a text (Varchar) or date value is being entered then the value entry for the text must be enclosed with single quotes (e.g. 'text'). Int, real, and bit values do not require this.

SQL Script:

INSERT INTO [TableName]
([Column 1 Name]
,[Column 2 Name]
,[Column 3 Name]
,[Column 4 Name])
VALUES
([Column 1 Value]
,[Column 2 Value]
,[Column 3 Value]
,[Column 4 Value])







Return to all articles