Search
Database

SQL Server 2008 : Demystifying Data Types - Computed Columns

Published 2 min readBy Programming4us Editorial Team
A computed column is calculated from an expression that can use other columns in the same table. The expression can be a noncomputed column name, constant, function, and any combination of these connected by one or more operators. The expression cannot be a subquery. Computed columns are virtual and are not physically stored in the table. The computed column is recalculated every time the computed column is referenced in a query. The expression used for the computed column is stored in the Computed Column Specification column properties.

An example of a computed column can be found in the Sales.SalesOrderHeader table in the AdventureWorks2008 database. See Figure 10.1 for an example of the computed column properties.

Figure 1. Computed Column Properties


Warning

Be able to define computed columns and explain how they are created.


Filestream Data Type

Tip

You have a great deal of information to keep track of. You’ve gotten this far ... You are doing great!


New in SQL Server 2008, the FILESTREAM storage attribute can be used for binary (BLOB) data to be stored in a varbinary(max) column.

Utilizing the FILESTREAM storage attribute has the following benefits:

  • Since the data is stored on the file system, performance matches the streaming performance of the file system.

  • The BLOB size is only restricted by the file system volume size.

  • The FILESTREAM columns are fully integrated with SQL Server maintenance operations, such as backup and restore.

  • SQL Server provides full transactional support between the relational data in the database and the unstructured data physically stored on the file system.

  • The SQL Server security model is used to manage FILESTREAM data.

Warning

Be sure to be familiar with the new features, such as FILESTREAM storage, available in SQL Server 2008.


In order for this storage attribute to be used, an attribute can be set on a varbinary column so that the data is stored on the file system. Doing this gains the benefits of the fast streaming and storage capabilities of the file system. The data is managed and accessed directly within the context of the database. The data is stored in the local NTFS file system and not in the database file.