Wednesday, 15 June 2011

SQL Server : stored procedure or function -



SQL Server : stored procedure or function -

i have table 2 columns (a bool , b text), these columns can be:

both null if false, b should null if true, b should not null

there rules. want create stored procedure or function check these rules when row adding or updating (via trigger). better, stored procedure or function? if function, type? in general, variant best (return boolean or other way etc)?

i think you're after check constraint.

example:

alter table xxx add together constraint chk_xxx check ( (a null , b null) or (a = 0 , b null) or (a = 1 , b not null) ) ;

sql-server function stored-procedures

No comments:

Post a Comment