CREATE TABLE [dbo].[Countries](
[CountryID] [INT] IDENTITY(1,1) NOT NULL,
[CountryCode] [NVARCHAR](5) NULL,
[CountryCodeLong] [NVARCHAR](5) NULL,
[CountryName] [NVARCHAR](50) NULL,
[CountryDescription] [NVARCHAR](100) NULL,
[Nationality] [NVARCHAR](20) NULL,
[CreatedDate] [DATETIME] NULL,
[IsActive] [BIT] NOT NULL
CONSTRAINT [PK_Mindcracker_Countries] PRIMARY KEY CLUSTERED
(
[CountryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON
[PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Countries] ADD CONSTRAINT [Countries_CreatedDate] DEFAULT (GETDATE()) FOR [CreatedDate]
GO
ALTER TABLE [dbo].[Countries] ADD CONSTRAINT [Countires_IsActive] DEFAULT ((1)) FOR [IsActive]
GO
In the given above script, we have 2 fields, which are set with default values. By using the given below script, we can see all the fields which have been set with the default values in a database.
Loading

Join the conversation! Your thoughts help the community grow.