MS SQL Server Concepts and Programming Question:
Download Questions PDF

How To Use Column Default Values in INSERT Statements in MS SQL Server?

MS SQL Server Interview Question
MS SQL Server Interview Question

Answer:

If a column is defined with a default value in a table, you can use the key word DEFAULT in the INSERT statement to take the default value for that column. The following tutorial exercise gives a good example:

INSERT INTO ggl_links VALUES (102,
'www.globalguideline.com',
NULL,
0,
DEFAULT)
GO
(1 row(s) affected)

SELECT * FROM fyi_links
GO
id url notes counts created
101 www.globalguideline.com NULL 0 2006-04-30
102 www.globalguideline.com NULL 0 2007-05-19

The default value, getdate(), is used for "created" column, which gives the current date.

Download MS SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
How To Insert a New Row into a Table with "INSERT INTO" Statements in MS SQL Server?How to provide column names in INSERT Statements in MS SQL Server?