Default Keyword IN SQL server

--DEFAULT IN SQL server

--How to use the default keyword in SQL?
--Default value in the SQL server

--Enter the default value in the SQL table

------------------------------------------------------

--Default keyword is used to insert some specific values.

--If you are not inserting anything into the specific column, then it will take the default value
--It is very easy; all you need to do is just look at the example to clear your concept

--Create a table with the default value

CREATE TABLE EMP

(
[ID] [int] IDENTITY(1,1) NOT NULL,
[EMPNAME] [varchar](10) NULL,
[CREATEDON] [datetime] NOT NULL

)
ON [PRIMARY]

GO

ALTER TABLE EMP ADD DEFAULT (getdate()) FOR [CREATEDON]
GO

-----------Note------------------

--You can also use the default inside the create table, but I have taken it separately so that you are able to understand it easily

--Here, the getdate() will display today's date if the user is not entering any date
--Insert into EMP

Insert into EMP (EMPNAME) values('Ashok')

--See your output

select * from EMP