O'Reilly logo

Microsoft® SQL Server™ 2000 Programming by Example by Carlos Eduardo Rojas, Fernando G. Guerrero

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Indexes on Computed Columns

In SQL Server 2000, you can create computed columns in a table. These columns don't use storage space, and SQL Server maintains them automatically whenever the underlying data changes.

You can create a computed column SalePrice in the [Order Details] table to get the total sale value of every row, considering the unit price and quantity. To speed up the process of searching, or sorting, for this SalePrice column, you can create an index on this computed column, and Query Optimizer might use it, if necessary. Listing 6.33 shows the complete process.

Code Listing 6.33. It Is Possible to Create Indexes on Computed Columns
					 USE Northwind GO -- Create the computed column SalePrice ALTER TABLE [order details] ADD SalePrice ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required