Enterprise manager and constraints

Mondeo

Well-known member
Joined
Nov 10, 2006
Messages
128
Location
Sunny Lancashire
Im using MS SQL 2000 with enterprise manager

I have a customers table called high_customer, it has a primary key called ID

I have an invoices table called high_invoices, it has no primary keys but it does have a column for customer ID.

I want to set it so if a customer is deleted from the customers table, any invoices with that customerID are deleted from the invoices table.

Do I need to specify a constraint? If so how do I do it in enterprise manager.

Thanks
 
Delete Rule = Cascade

If you havent already, you need to add a relationship between high_invoices and high_customer.

When editing the columns for high_invoices, right click anywhere in the columns list, and select Relationships. Then click the ... button by Tables and Columns Specification. Set the Primary key table to high_customer, and below that select the field in high_customer you wish to relate to (customer ID). On the right select the field in high_invoices that links to the customer ID and click OK. Then, under DELETE and UPDATE specification set the Delete Rule to Cascade.

If youve already added the relationship, then you just need to edit the Delete Rule as described above.

Good luck :cool:
 
Back
Top