arrow_backwardBack to SQL Server code examples

SQL Server Alter Column Default Example

How to change a column's default value in SQL Server
A common example for a created_at column - setting the default to the time that the record was created
ALTER TABLE
  [users]
ADD
  DEFAULT SYSUTCDATETIME() FOR [created_at]
Making the default value static
ALTER TABLE
  [users]
ADD
  DEFAULT 'Mateo' FOR [first_name]

Using Beekeeper Studio?

Beekeeper Studio is a free and open source database manager for Windows, Mac, and Linux.

This feature is baked right in, so there's no need to manually type SQL every time. Access column editing by right-clicking on a table in the sidebar and clicking 'View Structure'.

Download Beekeeper Studio