Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 check contraints question

Author  Topic 

mjorden
Starting Member

2 Posts

Posted - 2010-11-16 : 11:57:46
I am working on a project using Microsoft SQL Server 2008 R2. I have several tables. These tables include vendors and products. One of the requirements of the project is the need to "disable but not delete" a vendor and product entry. I am fairly certain I have to use a check constraint for this, but I am unsure has to how to proceed specifically. Any assitance is appriciated.

Thank you!

mjorden
Starting Member

2 Posts

Posted - 2010-11-16 : 12:12:48
I am sorry if this is the wrong forum. I am new to SQL and really need some help with this. I have done a lot of searching and am coming up empty handed.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-11-16 : 12:25:06
Add a column to the vendor table to indicate status. for example, 0 = disabled, 1 = active.

at the application level check this value to determine actions allowed.

You could add a trigger to the products table to rollback inserts from disabled vendors.

problem with a check constraint is that it will fail when you disable vendors that already have products in the product table.

show us what you have so far
Go to Top of Page
   

- Advertisement -