The T-SQL INSERT Command Syntax
|
|
|
|
| Articles Reviews Structured Query Language | |
| Written by Robin Dewson | |
| Tuesday, 29 May 2007 | |
|
Before it is possible to insert data using T-SQL code, you need to be familiar with the INSERTcommand and its structure.
INSERT [INTO] However, it is better to use square brackets, because there will be times you wish to set a value such as Acme’s Rockets to a column data, which can be added easily by surrounding it by double quotation marks. I cannot stress enough that really, there is nothing to be gained by using reserved words for table, views, or column names. Deciding on easy-to-use and unambiguous object names is part of a good design. However, this is a potentially dangerous scenario. If you build an INSERT command which you then saved and used later, you expect the columns to be in a specific order because that is the way they have always been. If someone then comes along and adds a new column, or perhaps alters the order, your query or stored procedure will either not work or give erroneous results, as values will be added to the wrong columns. Therefore, you have to use the VALUES keyword, especially if you omit the list of columns as explained previously. To clarify, if there are ten columns listed for data to be entered, then there must be ten values to enter. Powered by jReviews |
|
| Last Updated ( Friday, 04 January 2008 ) | |
| < Prev | Next > |
|---|







