Quantcast
Channel: VBForums - Database Development
Viewing all articles
Browse latest Browse all 2918

SQL Server constraint on multiple columns

$
0
0
I would like to enforce a constraint on an SQL Server table as follows:

Table definition

ComputerID autoinc
ComputerName varchar(255)
Username varchar(255)
IsDefault bit

ComputerName may have multiple records with the same value but only one of them should have IsDefault set to 1. The constraint should not allow the same ComputerName to have multiple records with IsDefault = 1.

How can this be achieved?

Viewing all articles
Browse latest Browse all 2918

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>