Skip to content

Instantly share code, notes, and snippets.

View gavincampbell's full-sized avatar

Gavin Campbell gavincampbell

View GitHub Profile
@gavincampbell
gavincampbell / SingleRowTable.sql
Last active December 17, 2015 14:44
Pattern for creating tables that can only ever have one row.
CREATE TABLE ConfigTable(
[ConstrainToSingleRow] [BIT] NOT NULL DEFAULT ((1)),
SomeValue [INT] NULL,
A_String [VARCHAR](10) NULL,
Flag1 [BIT] NULL DEFAULT ((0)),
Flag2 [BIT] NULL DEFAULT ((0)),
A_decimal [DECIMAL](9, 2) NULL,
PRIMARY KEY CLUSTERED
(