how to create rule for validating a column value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lovelydpka
    New Member
    • Mar 2010
    • 1

    #1

    how to create rule for validating a column value

    HI
    I m new to SQL server. Still as per my understanding "constraint check" can be applied on single column value and "rule" can be used where we want to validate all value of a single columns. For example, my table has following columns:-
    username: varchar(50)
    password: varchar(50)
    Active: int ( It will have value 0 or 1, 0 mean Not active and 1 means Active )

    I want to validate that only one row should contain "Active" = 1 at a time. It is possible that, no row have "Active" =1. But I should not happen that more that 1 row have "Active"=1 at an instance.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Yes. Use INSTEAD OF trigger instead.

    Happy Coding!!!

    ~~ CK

    Comment

    Working...