troubleshooting Question

Inserting data from one table to another with NULLS in SQL Server / Coldfusion

Avatar of diecasthft01
diecasthft01 asked on
Microsoft SQL ServerColdFusion LanguageSQL
8 Comments1 Solution18 ViewsLast Modified:
Good morning. I am hoping to get some assistance with an SQL / CF query. I have a CF app that part of it queries an existing table in SQL Server and then inserts that data into another empty SQL Server table. This worked fine in Oracle but in my migration to SQL it fails. The problem seems to be that the insert fails at a specific field (EXPENSES) becasue that field has NULLS in it. My SQL "EXPENSES" field is a numeric field (18,2). My code is below:
First I grab the data from the existing table:
<cfquery name="ListERP19" datasource="SQL_MCA">
Then I insert it into the new table.
<CFLOOP query="ListERP19">
<cfquery name="COPYNEWcsv" datasource="SQL_MCA">
                  ( '#ListERP19.ALLOTMENT#',
                   <cfqueryparam value="#ListERP19.EXPENSES#" scale="2" cfsqltype="CF_SQL_NUMERIC" null="no">,
                  '#ListERP19.WBS_ALL#' )   
I even tried this:
case when '#ListERP19.EXPENSES#' is null then 0 else '#ListERP19.EXPENSES#' end,
And it didnt work either. The first three insert values work, basically becasue there are no NULLS in those three values. Any help/guidance would be greatly appreciated
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros