.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Articles >> DataBase >> Post New Resource Bookmark and Share   

 Subscribe to Articles

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

Posted By:Syed Shakeer Hussain       Posted Date: June 21, 2009    Points: 25    Category: DataBase    URL: http://www.dotnetspark.com  

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:


 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend