Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
(
[ConstrainToSingleRow] ASC
)
) ON [PRIMARY]
ALTER TABLE ConfigTable WITH CHECK ADD CHECK (([ConstrainToSingleRow]=(1)))
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.