Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a rule?

Status
Not open for further replies.

sqlval

Programmer
Jan 12, 2011
10
US
I need to create a rule that one table field should be populated if there is a particular value in another field: if col1 = "Value" then col2 is not null. How do I do it? Is it a rule or an expression in the computed column property?
Thank you for your help.
 
Sounds like you need to add a constraint to your table. Something like this....

Code:
Alter Table    [!]YourTableName[/!] 
Add Constraint [!]NameOfConstraint[/!] 
CHECK(NOT (Col1 = 'Value' And Col2 Is NULL))


-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top