In SQL Server 2005, if you create a view utilizing the TOP (100) PERCENT and ORDER BY clauses, you will not get back your results in the order specified.
Example:
USE AdventureWorks
GO
CREATE VIEW CustomersOrderedbyTerritory
AS
SELECT TOP(100) PERCENT * FROM Sales.Customer
ORDER BY TerritoryID
GO
SELECT * FROM customersOrderedbyTerritory
You will notice that SELECTing from this view returns a result set 'ignorant' of the ORDER BY directive. In essence, the optimizer ignores the TOP and ORDER BY clauses. To achieve the desired result, there is a hot fix available from MSFT which introduces trace flag 168 and also requires you set the database compatibility level to 80 (SQL Server 2000).
Apparently, the problem also extends to Common Table Expressions (CTE) which use the same constructs such as :
WITH territorialcustomers AS
(
SELECT TOP(100) PERCENT * FROM Sales.Customer
ORDER BY TerritoryID
)
SELECT * FROM territorialcustomers
If you don't want to set your compatibility level to 80, you can use TOP (99.999999999999) instead. This somehow fools the optimizer to sort the data the way you want it to. Of course, it is only useful if your table contains less than 10 million records since the 0.000000000001% difference may start to show.
Well, if you insist on using the view, you can avoid the hot fix by using the ORDER BY clause in a table-valued function to retrieve your ordered data . You can then wrap your view around this UDF.
I have not checked if this behavior has been carried forward to SQL Server 2008.

Do you routinely open new folders directly, either because you created one on your
desktop, through a shortcut, or by using the new context menu in Visual Studio to
explore the folders in your solution? Are you constantly adjusting the size of the
Explorer windows because they are too large or too small for your tastes? Do you
wonder why Vista does not just remember and open all windows at the same size?
Vista stores settings such as size, location, sort type, icon type, etc… for individual
folders you open. Some of these settings can be replicated to other folders using
Folder Options / View / Apply to Folders, but that method is not very reliable and
no longer applies to all folders as it did in previous versions of Windows.
Vista can still later decide that your documents folder is suddenly a music folder,
or your apps folder full of only executables is now a picture folder.
There are some registry settings you can apply that will take care of most of theses
issues, except window sizes. I first discovered the settings through a link in the
comments on
Scott Hanselman's post about Vista’s erratic file type views. Later, after
I purchased a new laptop
I came across a better explanation on the My Digital Life blog. If you are
looking for a way to fix this behavior, I would suggest going there first as this
fix is an expanded version of it and requires those steps. Come back here before
you open any new windows though. Go ahead… I’ll keep myself busy.
Ok, now that you have completed those steps, we can get that pesky window size issue
fixed.
First, right click on your desktop and choose New / Folder.
Next, double click the new folder and drag it out or in to your preferred size.
You can also set other properties of the window you want to be the default at this
point. For instance, I like by default window view to be details view grouped by
the type of item. The folder is empty so you will not see any sorting or grouping,
but it will be saved.
Close the window and open the registry editor, type regedit.exe in the quick search
bar of the start menu.
Important, The next steps involve editing your registry. The standard
disclaimer applies. You can cause serious problems if you are not careful in the
registry. Follow these steps though and your computer will survive.
Navigate back to the registry key:
[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\.
You should see a single numbered key under the Bags key. That key represents the
settings for the folder you just closed. Open the ‘Shell’ key beneath it and you
should see another key with a guid name such as ‘{5C4F28B5-F869-4E84-8E60-F11DB97C5CC7}’.
The numbers may be different on your system.

Right click the guid key and choose export. Save the file to your desktop. Use any
name you like.

Now that you have a new registry settings file on your desktop, right click the
file and choose Edit. You need to make a single change. The second line in the file
will be the path in the registry, it will look like:
[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\4\Shell\{5C4F28B5-F869-4E84-8E60-F11DB97C5CC7}].
The piece that needs to be changed is the number after the ‘Bags’ key. In this case
it is 4, but your file may be different. Change the number to ‘AllFolders’ so that
the line looks like:
[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell\{5C4F28B5-F869-4E84-8E60-F11DB97C5CC7}].
Save and close the registry settings file. Now to get these settings back into the
registry, double click the file and choose ok at the prompt.
Open any folder on your computer and it will look exactly like your first folder.
You will need to reset any special folder views you had, such as picture folders.
You can do that in two ways. Click the ‘Views’ button at the top of any window or
right click in a window and choose ‘Customize This Folder’. Once you have made your
change, close the window and Windows will remember the setting for that folder.

Like last year, I'm heading out to the MVP Summit in Redmond. Here's some information on the event:
The upcoming summit, April 14-17, will feature a keynote from Microsoft CEO Steve Ballmer and closing by Chief Software Architect Ray Ozzie, in addition to several sessions, including topics ranging from social media for peer-to-peer support to new developments such as Silverlight mobile to Skydrive. Nearly 1,800 MVPs are planning to attend.
In conjunction with the summit, the Code Trip (www.thecodetrip.com), which launched from MIX and has been traveling around the western U.S., is an RV housed with Microsoft developer evangelists spreading the word about new technologies and meeting MVPs at each stop. The final destination of the 21 city trip is the MVP summit.
