ALTER TABLE [CMST_Country]
ADD CONSTRAINT uc_CountryCode UNIQUE (Code)
SQL, C#, VB, .net, asp, JavaScript, you name it. Code samples, Error messages and stuff like that. Please add coments if you think I said something stupid :D or if you have a better idea ... or anything at all ...
Showing posts with label constraint. Show all posts
Showing posts with label constraint. Show all posts
Thursday, November 5, 2009
Wednesday, February 25, 2009
How to add a constraint on a table that has 2 iD columns
How to add a constraint on a table that has 2 iD columns
The idea is that both id columns have allow nulls, but you would like to have an ID at least in one of them all the time.
This is how you do it:
ALTER TABLE [PTCTSS_FactorGroup] ADD
CONSTRAINT [CK_PTCTSS_FactorGroup_2cols] CHECK (((not([ContractSectionId] is null))) or ((not([CustomModuleId] is null))))
GO
Thanks 2 Cris ;)
The idea is that both id columns have allow nulls, but you would like to have an ID at least in one of them all the time.
This is how you do it:
ALTER TABLE [PTCTSS_FactorGroup] ADD
CONSTRAINT [CK_PTCTSS_FactorGroup_2cols] CHECK (((not([ContractSectionId] is null))) or ((not([CustomModuleId] is null))))
GO
Thanks 2 Cris ;)
Subscribe to:
Posts (Atom)