Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Constraint on 2 fields
Message
De
14/02/2006 03:27:35
Jon Neale
Bond International Software
Wootton Bassett, Royaume Uni
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01096008
Message ID:
01096075
Vues:
11
Einar,

You would need to use a table level constraint, this allows you to use more than one field.

Here's a snippet from another site:

For example, the following create table statement has a check constraint that operates on two columns, pub_id and pub_name:

create table my_publishers
(pub_id char(4),
pub_name varchar(40),
constraint my_chk_constraint
check (pub_id in ("1389", "0736", "0877")
or pub_name not like "Bad News Books"))


Jon

>Consider the following table structure:
>Id uniqueidentifier
>ControlId bigint
>Number tinyint
>field_0 varchar(10)
>field_1 varchar(10)
>.
>.
>field_n varchar(10)
>
>The Id field is my PK, but I would also like to add a unique constraint on the "combination" of the fields ControlId and Number. How can I do this? Please let me know if what I am asking is very unclear.
>
>Thanks,
>Einar
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform