Article Information
This SQL Tutorial contains and tries to cover following subjects:
- Explanation of inserting a row into table in sql.
- Example to insert a row in sql
Articles tries to provide answer to following questions
- How to a new row into table in sql server?
- How to add a new record to a table in sql server?
- How to add a new record to database in sql?
- What is INSERT in sql?
- How to use INSERT command in sql server?
Article covers followings indirectly:
- alter view in sql
Articles pre-requisites following information:
- General knowledge of SQL Server Management Studio
- General knowledge of Views
Insert a row into table in SQL
Iserting a row in sql is one the main data modification command. We had covered INSERT command in sql in earlier articles briefly as a simple row insert.
To recall again briefly the INSERT; INSERT command allows sql programmer to add a new row into a table in sql. To go into types of INSERT detailed in sql, in that first part we will first insert a new row in simple form of SELECT. INSERT command gets column names, and the values to be inserted into that columns. Lets check how is the basic INSERT syntax.
INSERT (column1, column2) VALUES (value1, values2)
Above is basic syntax for INSERT command to add a new row into table. There are some important points in the command. The column names and values need to match as order. In above command, value1 will be inserted to column1, value2 into column2 and goes that way. In other words, in an INSERT statement, column names have to be listed correctly. Value types also have to match the type of the column: otherwise it ends with error. For instance: if column1 is a nvarchar column, and value1 is an int, it ends up with error.
INSERT
We covered INSERT with theory, lets insert a row in a table in practice to see how things work.
Example of Inserting a row to table in SQL
Following sql example demonstrates how to insert a new row into table in sql server.
As above indicates, a new row has been inserted into the table. We provided two column name and two value to be inserted. New row is added to table.