My first choice would be to resolve the db issue if possible, but if that could 
mess up other areas of your application or you aren't able to do that just 
'yet', try this:

insert into 
        [user] 
( name <CFIF IsDefined("#departmentvalue#")>, departmentId</CFIF> )
        values
{ '#namevalue#' <CFIF IsDefined("#departmentvalue#")>', 
#departmentvalue#'</CFIF> )

something to that effect...

Dave
-----Original Message-----
From: Dan G. Switzer, II [mailto:[EMAIL PROTECTED]
Sent: Friday, July 22, 2005 11:35 AM
To: CF-Talk
Subject: MSSQL Contraint/Null Issue...


I've got a problem I've never run into before. In the application I've
recently inherited they've defined a constraint between two columns.
However, in the table that references the primary key the column can
actually contain a null value. 

The problem I'm running into is if I try to insert the data w/a null value I
get a constraint issue, if I leave the column out completely then no
constraint issue is passed.

Example:
insert into
        [user]
( name, departmentId )
        values
( 'dan', null)

That throws an error, while this won't:

insert into
        [user]
( name )
        values
( 'dan' )

The problem is I'm trying to do some operations in bulk so sometimes the
departmentId will be there and sometimes it won't. 

Is there a way around this?

Thanks,
Dan





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:212576
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to