SQL Query Help
Posted on 2014-04-01
I have a really massive SQL query that I use to run an export from one CRM into another CRM package. I just uncovered a problem with my query and I am not sure how to fix it. My basic syntax is this:
With C1 As
select c1.value, C2.value
left join c2
I have 17 different joins here because this query is huge. Here is my question. One of the select queries in the top part of the statement is returning a null value sometimes. When it returns a null I need to run a different query to produce the correct values. I always have trouble creating programming logic in SQL but I basically want:
if query = NULL then query2.
Can anyone make any sense of this and tell me how I can accomplish this? I am running in MS SQL 2008.