Groups | Blog | Home
all groups > sql server new users > may 2006 >

sql server new users : Using a formula in a table field


Conan Kelly
5/4/2006 10:47:45 AM
Hello all,

Using SQL Server 2000 (Standard Edition, I think).

I was trying to educate myself on creating functions and in one of the examples in Books Online I noticed that you could use
formulas in fields in a table, calculating the field value using other fields as arguments.

My question is this: Is this like a calculated field in a query/view and is recalculated every time the table is opened/queried or
is the field only calculated once during data input and that value is stored in the field?

Thanks for any help anyone can provide,

Conan Kelly

Stu
5/4/2006 7:39:25 PM
Hey Conan,

Calculated columns are recalculated whenever the underlying data
changes; if you update a value in a column used in the calculated
columns formula, then the data will change.

A couple of notes though:

1. Tables don't have fields; they have columns, rows, and tuples. It
may seem a bit pedantic, but terminology is important.

2. Most implementations of SQL don't use computed columns because it's
a violation of the basic design of a table (look up ACID tests in SQL).
Computed columns can be useful when dealing with large tables (for
performance reasons), but it's one of those things that Microsoft touts
as a great feature, but it really should only be used sparingly.

HTH,
Stu
AddThis Social Bookmark Button