The attached script is executed nightly to gather data used for a crystal report.
The issue I'm having is the case statement at the column name pyulast.
These scripts work fine in Tsql with values rather than variable name. ie:"12345' rather than clientid.
there are two sets of statement to execute depending on the value in company_record column.
the when = 0 statement fails while entering the code. I want the value of pyulast to be the result of either set depending on value of company_record.
Another set of eyes would be helpful