Last active
December 17, 2015 14:44
-
-
Save gavincampbell/679b9486095e3e43639d to your computer and use it in GitHub Desktop.
Pattern for creating tables that can only ever have one row.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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