title: Using a scalar-valued function as a parameter to another SVF
body: <p>I have a handful of scalar-valued functions (which I appreciate may not be best practice, but for now, this will suffice, this is simply a development exercise) which I use within various computed columns with MS SQL tables.</p>
  <p>I have a scenario whereby I need to use the result of one of these functions, as a parameter to another within a given computed column. For example;</p>
  <pre><code>(case when [DynamicQuantity] IS NULL then ([dbo].[GetFiatValue]([Currency],[Quantity])) ELSE ([dbo].[GetFiatValue]([Currency],([dbo].[getStakedQuantity]([currency])))) end)
  </code></pre>
  <p>If the given <code>[DynamicQuantity]</code> field is null (a column value generated by another SVF), use the <code>[Quantity]</code> field. However, if <code>[DynamicQuantity]</code> is populated, the <code>ELSE</code> will fire, and pass the output of the <code>[dbo].[getStakedQuantity]</code> SVF in place of the <code>[Quantity]</code> value.</p>
  <p>Is this achievable? I can't seem to get the syntax to work and am questioning whether this is even possible?</p>
  <p>Running it via a normal query works;</p>
  <pre><code>SELECT case when [DynamicQuantity] IS NULL then [dbo].[GetFiatValue]([Currency],[Quantity]) ELSE [dbo].[GetFiatValue]([Currency],[dbo].[getStakedQuantity]([currency])) end from dbo.cryptoPortfolio
  </code></pre>
  <p>But when used as a computed column formula below;</p>
  <pre><code>case when [DynamicQuantity] IS NULL then [dbo].[GetFiatValue]([Currency],[Quantity]) ELSE [dbo].[GetFiatValue]([Currency],[dbo].[getStakedQuantity]([currency])) end
  </code></pre>
  <p>SSMS will not accept it, with <code>Error validating the formula for column 'FiatValue'.</code></p>