Hi all,If I have 1 table like this currently:[code="sql"]CREATE TABLE [dbo].[tbl_MyTable]( [VhID] [int] NOT NULL, [CreatedUTC] [datetime2](3) NOT NULL, [ExtID] [varchar](50) NOT NULL, [ORS] [tinyint] NOT NULL, [PrID] [int] NOT NULL, CONSTRAINT [PK_tbl_MyTable] PRIMARY KEY CLUSTERED ( [VhID] ASC)) ON [PRIMARY][/code]And now there are two new UNIQUENESS requirements that state that: 1) We can't have duplicates in VhId & ExtId combined2) We can't have duplicate in ExtId & PrId combinedbut VhID and PrID can be the same in one row so long as ExtID is differentheres an example of case which SHOULD be possible:[code="sql"]VhID | ExtID | PrID 1 | abc | 2 1 | cde | 2 2 | cde | 3[/code]here are examples of cases that should *NOT* be possible :This first example violates rule 1)[code="sql"]VhID | ExtID | PrID 1 | abc | 2 1 | abc | 3[/code]Second example violates both rules[code="sql"]VhID | ExtID | PrID 1 | abc | 2 1 | abc | 2[/code]Third example violates rule 2)[code="sql"]VhID | ExtID | PrID 1 | abc | 2 2 | abc | 2[/code]Whats the best way to approach this?
↧