Computed column using replace

Computed column using replace

I have created a computed column using replace in a view that might be useful for others and decided to share it. My query-based view has many tables in the datasource. It is showing all possible combinations of PaymTerm and CashDisc for some reasons that are not relevant here. This field is the code or id field for the combinations. When there is no cash disc I have to return  ‘PaymTerm.PaymTermId’ else I need to return a combination of ‘PaymTerm.PaymTermId’ and ‘CashDisc.CashDiscCode’ but unfortunately there is the character ‘%’ used in the database for the discount code and that should be excluded in the result.

The solution was the combination of  ‘SysComputedColumn::if’, ‘isNullExpression’ and as there was no function for ‘replace’, I had to create my own code for that.

Computed column X++ code

Computed column in SQL


Leave a Reply

Your email address will not be published. Required fields are marked *