How To Create Computed Columns In Sql Server 2008


show more Creating computed columns provides you with in-depth training on Business. Taught by Simon Allardice as part of the SQL Server 2008 Essential Training show less
please wait ...

Creating computed columns

There is a column that you can add to your tables that comes in handy from time-to-time and really it's not a real column at all. What it is, is a calculated or computed column. So let's say for example we're working with this OrderItem table, and I've got multiple entries here. I've only got 20 or so but we could have 50,000 of them that deal with ProductIDs, Quantities and UnitPrice. Or you might find it useful to have kind of a rolling total of each order item going, particularly if you've got a lot of separate quantities.

So instead of having to load this data into an application to then perform a calculation, it just might be nice if each order item entry had its own little subtotal. So we can do that of course. We could just add a regular column. I'll go into that table into Design view and I'll add a new column called Total. I'll make it a money column, save my changes, I've allowed Null so won't complain about that right now, and then I...

Creating computed columns
Video duration: 3m 10s 6h 54m Beginner

Viewers:

Creating computed columns provides you with in-depth training on Business. Taught by Simon Allardice as part of the SQL Server 2008 Essential Training

Subjects:
Business Developer IT
Software:
SQL Server
Author:
please wait ...