I am creating an import process where I ultimately need a SELECT of several fields along with a computed value. The logic of the computed value is rather complex, I'll need to do it in a UDF rather than in the SELECT itself.
The problem is that the computed value is determined by the contents of 30-40 columns... What I've considered:
- A monster function with 30-40 input parameters.
- Write a SP or C# app to loop through the selected data. This option is likely not as future-proof as the others.
- Passing the entire record's contents as JSON as a single parameter and pull the appropriate fields in my UDF. I'd need to combine columns and JSON in a select as shown here.
Any ideas for a better solution? I'm leaning towards the last one.
To further worsen this situation is that the data is not on the server that I plan on running the UDF, and that server is older (does not support FOR JSON clause). But I can clumsily get around this part with OpenQuery().