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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with a Null/Not null problem

Status
Not open for further replies.

PJYelton

Programmer
Jan 29, 2003
19
US
Hi, I am fairly new to SQL and we are trying to create a table that contains an attribute named Call_Type and an object named Score_Type. Now if Call_Type is 'I' or 'C' then Creativity which is a part of Score_Type cannot be null, otherwise it can be. I'm not sure how to program this though with SQL. I know how to set it to null or not null, but not how to make this property dependant on another attribute.
 
Try this and see if it is what you are looking for:

Create a table with that column Null and then alter column based on the value of this column...

IF exists (Select CallType From TableName Where CallType = 'C' or CallType = 'I')
Alter Table [TableName]
Alter Column [Column Name] type NOT NULL
 
But would this give an error when trying to insert into the table a value of 'C' and a null but not when I insert a value of 'X' and a null? This is what I am trying to accomplish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top