Im having a bit of design quandry... I need to return a result set of calculated values based upon multiple columns of data. Basically they are size calucations based on a table with Height, Width, and Thickness...
In T-SQL... (simplified, AdjustWidth involves CASE and gets complex)
TotalWidth depends on "AdjustWidth" but it cannot be reffered to directly because is not a column. Id like to be able to do something like this, with a local variable
But this is not allowed in T-SQL. And I would need to return the variables in the result set.
I could write the calculation all inline like the first example but it gets incredibly confusing and longer the deeper I get (mostly due to CASE statements). I could write the adjustments as functions but then calling the same functions over and over.
I could build out a DataSet programmatically, but then Id have some deployment issues. Any ideas on how to accomplish something like this on the back end?
Im thinking about attempting to do this with CLR in 2005... Thoughts?
In T-SQL... (simplified, AdjustWidth involves CASE and gets complex)
Code:
SELECT [INDENT]Height,
Width,
Thickness,
AdjustWidth = Width - 1,
AdjustThickness = Thickness + 4,
TotalWidth = 2*Width + Thickness + 2
TotalTimes8 = 16*Width + 8*Thicknes + 16[/INDENT]
Code:
SELECT [INDENT]Height,
Width,
Thickness,
@AdjustWidth = Width - 1,
@AdjustThickness = Thickness + 4,
@TotalWidth = 2*@AdjustWidth + @AdjustThickness
TotalTimes8 = 8*TotalWidth[/INDENT]
I could write the calculation all inline like the first example but it gets incredibly confusing and longer the deeper I get (mostly due to CASE statements). I could write the adjustments as functions but then calling the same functions over and over.
I could build out a DataSet programmatically, but then Id have some deployment issues. Any ideas on how to accomplish something like this on the back end?
Im thinking about attempting to do this with CLR in 2005... Thoughts?