April 12, 2013 at 2:11 am
Hi All,
I have two Columns in my Table Status A and Status B.
I want to create a Default Constraint for column Status B based on the Value from Status A.
If Status A = 1 then Status B = 1
If Status A = 0 then Status B = 0 ...
Both are Bit Data type. Is it possible to Create a Default Constraint to assign Status B with value in Status A.
Thanks in Advance...
April 12, 2013 at 7:48 am
ard5karthick (4/12/2013)
Hi All,I have two Columns in my Table Status A and Status B.
I want to create a Default Constraint for column Status B based on the Value from Status A.
If Status A = 1 then Status B = 1
If Status A = 0 then Status B = 0 ...
Both are Bit Data type. Is it possible to Create a Default Constraint to assign Status B with value in Status A.
Thanks in Advance...
You can't have a default with conditions. You could use a calculated column or do this type of thing in an insert trigger.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 12, 2013 at 7:55 am
pmfji, but maybe a table level check clause could accomplish your goals?
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply