views:

602

answers:

3

in a table two of columns are billable(bit),billabledate(datetime).i want billable date to be not null if billable is not null.

A: 

I'd try adding a trigger to the table, on after insert and after update, to enforce that constraint. Check the billable value, and block insert/update in case it is not null and the billabledate is null.

Noam Gal
+2  A: 

Add a check constraint:

CHECK (billable is not null and billabledate is not null) OR (billable is null)

Rashack
+2  A: 

You need a Check Constraint

ALTER TABLE dbo.Table WITH NOCHECK
ADD CONSTRAINT CK_Table_BusinessRule CHECK (Billable IS NOT NULL AND BillableDate IS NOT NULL)

http://msdn.microsoft.com/en-us/library/ms179491(SQL.90).aspx

Dave Barker