Mega Code Archive

 
Categories / MSSQL Tutorial / Constraints
 

Unique Constraint

2>  CREATE TABLE customer_location 3> ( 4> cust_id                 int    NOT NULL, 5> cust_location_number    int    NOT NULL, 6> CONSTRAINT customer_location_unique UNIQUE 7>     (cust_id, cust_location_number) 8> ) 9> GO 1> 2> EXEC sp_helpconstraint customer_location 3> GO Object Name -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- customer_location constraint_type                                                                                                                                    constraint_name                                                                             delete_action update_action status_enabled status_for_replication constraint_keys -------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------- --------------------------------------------------------------------------- ------------- ------------- -------------- ---------------------- ---------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------- UNIQUE (non-clustered)                                                                                                                             customer_location_unique                                                                             (n/a)         (n/a)         (n/a)          (n/a)                  cust_id, cust_location_number No foreign keys reference table 'customer_location', or you do not have permissions on referencing tables. 1> 2> drop table customer_location; 3> GO