Sql Server Defaults

May 03 08:23 2011



defaults are used for inserting default values to tables when the field is skipped or inserted iwth default values

To dmonstrate lets create a table first


create table default_test
id int,
r_date datetime default(getdate()),
r_count int default(100)

Now insert values to fields except r_date

insert into default_test (id) values (1000)

r_date will be inserted with current date value

Again When the field is inserted with keyword default, this time too value on the r_date feld will be of current date

insert into default_test (id,r_date) values (1000,default)

But when insert value to this field it ll accept it over default

insert into default_test (id,r_date) values (1000,’2011-3-3′)

view more articles

About Article Author


a gadget and internet addict , a red hat certified linux administrator with skills in dataware development and online technologies., follow me on twitter @abhilashsnair

View More Articles