Tuesday, March 20, 2012

Re : Sql Server - table - formula

I am trying to use SQL Server table formula field. I have
two fields 'Field1','Field2' and I am using the formula
Field2/Field1. The problem is if I have 0 values in
Field1, I am getting errors. Is there a documentation as
what functions are supported in the formula field and how
to handle the above mentioned error.What do you want the value to be if there is a '0' in field1. You can
use a case statement...
Vijay wrote:
> I am trying to use SQL Server table formula field. I have
> two fields 'Field1','Field2' and I am using the formula
> Field2/Field1. The problem is if I have 0 values in
> Field1, I am getting errors. Is there a documentation as
> what functions are supported in the formula field and how
> to handle the above mentioned error.|||You can use a CASE expression or even NULLIF like:
CREATE TABLE tbl (
...
col1 INT,
col2 INT,
calc_col AS col2/NULLIF(col1, 0),
...);
--
- Anith
( Please reply to newsgroups only )

No comments:

Post a Comment