How to store a Default Value in a table using sqlserver ?

Posted by in Sql Server category on for Beginner level | Views : 6572 red flag

storing a Default Value in a Table

How to store a Default Value in a table using sqlserver?

Suppose there are 3 columns name, location and gender in a table called ‘default_tbl’.

I am going to insert record in a default_tbl.

In above output you can see I given only name and location values. I don’t want to make a gender column as null. if the user forgets to give the  value of gender, by default you have to store the value as MALE.

You have to set the default value of gender column. Open your Design Table, Select the gender column. In Properties Enter ’ Male‘ under Default Value.

See the below image how to set the default value:

Now I am going to insert records without giving a gender values. You can observer the output result in below image:


Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Syed Shakeer Hussiain P
Member Level:
Member Status: Member
Member Since: 2/5/2009 3:12:18 AM
Country: India
Syed Shakeer Hussain
Shakeer Hussain has completed his Master of Computer Applications degree from Deccan College of engg and technology of Osmania University.He is a MVM of has good experience in the areas of ASP.NET, C#.NET, VB.NET, SQL SERVER 2000/2005 and Windows Mobile. He has worked in Windows Mobile,Web Applicatin and ERP projects.

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)