Brettb.Com
  HOME | ABOUT ME | BIOTECHNOLOGY | ARTICLES | GALLERY | CONTACT
Search: Go
TECHNICAL ARTICLES
 ASP
 ASP.NET
 JavaScript
 Transact SQL
 Other Articles
 Software Reviews

PHOTO GALLERIES
 Canon EOS 300D Samples
 Akihabara Maids!
 More Galleries...

TRAVEL LOG
 2009: China
 2008: Tokyo
 2007: Tokyo
 2006: Hong Kong
 2005: New York City

MORE STUFF
 Search Engine Optimisation
 Build an ASP Search Engine
 My Tropical Fishtank
 Autoglass
 SQL Month Name
 SQL Get Date Today
 SQL Year Month
 Other New Stuff...

POPULAR STUFF
 Regular Expressions
 Index Server & ASP
 JavaScript Ad Rotator

Home > Articles > Transact SQL Programming Articles

Using the Transact SQL Insert Into Statement

The SQL Server Transact SQL Insert Into statement can be used to insert new data rows into a database table.

The basic syntax of the Insert Into SQL code is:

INSERT INTO <table name>
<column names>
VALUES
<column values>

A SQL code example of using the Insert Into statement is shown below:

INSERT INTO t_Products
(
ProductName,
ProductSKU,
ProductPrice
)
VALUES
(
'Microsoft SQL Server',
'MSSQL',
'$995'
)

Instead of specifying values as the actual data values to be inserted, it's also possible to specify SQL variables such as @ProductName. It's also possible to leave a column in the inserted row empty by specifying Null as the column value. If you've set up column defaults it's also possible to specify DEFAULT as the column's value. Finally, if you want to insert the current date into a row then use the GetDate() function.

Finally, a SQL Server table may be updated using an update query. Here is the SQL syntax for the table update query.

Useful SQL Utilities

  Site Map | Privacy Policy

All content is 1995 - 2012