How to Create Default

Firstly lets learn what is Default Value and how to Create Default.

In some cases when User doesn't input any value, for example we have Gender Column and if user doesn't input the value for Gender then by default you want to enter 'Male' in Gender Column.

Let Create a Default:
Execute this script:

USE [SQLServerTutorial]
GO
CREATE DEFAULT [dbo].[DF_Gender] as 'Male'
GO

Here we are creating DF_Gender (Default) which will set Male as Default Value.


No comments:

Post a Comment