Using Default Values in INSERTs

Recommendation:

When inserting, if there is a default value, add the column name as a comment in the INSERT statement.  This tells the reader that a column will be filled with data even though there is no explicit value being passed in the insert.

Example Code:

Table Schema:

CREATE TABLE dbo.ExampleTable (
    ExampleID       bigint      NOT NULL   IDENTITY(),
    ParentID        int         NOT NULL,
    ChangedByUserID int         NULL,
    Active          bit         NOT NULL CONSTRAINT ExampleTable_Active_DF          DEFAULT 1, -- Active when inserted
    DateLastUpdated datetime    NOT NULL
CONSTRAINT ExampleTable_DateLastUpdated_DF DEFAULT GETDATE(),

    CONSTRAINT ExampleTable_PK PRIMARY KEY CLUSTERED (ExampleID)
)
    

INSERT Command:

INSERT INTO dbo.ExampleTable (
    -- ExampleID
    ParentID,
    ChangedByUserID,
    -- Active
    -- DateLastUpdated
)
VALUES (
    @ParentID,
    @ChangedByUserID
)