MSSQL Default Values

If you want to use an integer and want to increment the value for each new record you can use this snippet:

ALTER TABLE mytable ADD mycolumn int IDENTITY(1,1) NOT NULL

To set default value to datetime column with actual time use this:

ALTER TABLE mytable ADD mycolumn datetime NOT NULL DEFAULT (getdate())

Did you like the article? Send me a comment!