You are here: Re: Reusing a generated column to avoid over processing « MsSQL Server « IT news, forums, messages
Re: Reusing a generated column to avoid over processing

Posted by Roy Harvey (SQL Server MVP) on 10/24/07 13:24

>
>> One approach is to use a view. Another is to use a derived table. For
>> SQL Server 2005 there is a third alternative, a Common Table
>> Expression (CTE).
>>
>> All three alternatives require writing the query that returns the
>> computed column and then using that query in any of the three ways. So
>> we could have something like:
>>
>> WITH Example AS
>> (SELECT A, B, C, <complex expression> as Complex
>> FROM X)
>> SELECT *
>> FROM Example
>> WHERE Complex = '20071225'

>I thought to divide in steps the performation of the calculumns.
>In the first step create a view that execute the basic calculation,
>and create another views that reuse the alread done work.
>
>But its seems to be very strange, cause its not a elegant solution.

Using views on views is one way to do it, but with the new feature of
Common Table Expression (CTE) in SQL Server 2005 we can avoid that.
You can have more than one CTE prefixing a command, and the succeeding
ones can reference the preceding ones. That means the nesting can all
be in the one command, much cleaner than views on views.

Roy Harvey
Beacon Falls, CT

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация