Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
bimpex
Starting Member
3 Posts |
Posted - 2009-02-07 : 05:30:43
|
hai all,wishes,i am very new to sql serveri am creating a table in that i want to make Check Constraintsfor column3 and column4 should be null are notnull(eigher one only should not have value, both have no value or value)thanks in advancercs----------------AC_HD_NAME_DR1 VARCHAR2(30)not nullJR_AMT_DR1 MONEY(20,2) not nullAC_HD_NAME_DR2 VARCHAR2(30)JR_AMT_DR2 MONEY(20,2) ----- |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-07 : 08:48:42
|
do you mean this?ALTER TABLE tablename ADD CONSTRAINT CHK_Col3_Col4 CHECK (Column3 IS NOT NULL OR Column4 IS NOT NULL) |
|
|
bimpex
Starting Member
3 Posts |
Posted - 2009-02-07 : 09:33:10
|
i need like this:1.both column can be null2.both column can be not null |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-07 : 09:40:41
|
[code]ALTER TABLE tablename ADD CONSTRAINT CHK_Col3_Col4 CHECK ((Column3 IS NOT NULL AND Column4 IS NOT NULL) OR (Column3 IS NULL AND Column4 IS NULL))[/code] |
|
|
bimpex
Starting Member
3 Posts |
Posted - 2009-02-07 : 10:00:43
|
hai,visakh16your ans solved my probthank you |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-07 : 10:03:36
|
welcome |
|
|
|
|
|