I have a function that sending a code gets a description through various formatings, I need to use the function inside a view in four columns but rather than calling it in the query I would like to associate it as a computed column (so we don’t have to modify the query/view if the function name or parameters changes so the DBA can manage it in the future…)
Is it possible?
Yes – you can do something like:
This adds a computed column to your table – and if the function is “deterministic”, you can even add the
PERSISTEDkeyword to it, so that the resulting value will actually be stored in the table (and the function isn’t call every time you select a row).