views:

637

answers:

4

In SQL Server Management Studio (SSMS) running against SQL Server 2005, I have a solution which contains a number of views.

These views are not sorted alphabetically.

Can anyone provide either an explanation of why, or a solution to order them alphabetically ?

+3  A: 

There is a tool that you can install to sort the contents of a SQL Server Solution project.

See the following reference.

http://www.sqldbatips.com/showarticle.asp?ID=78

Please ensure you save your work, before attempting a sort.

John Sansom
+2  A: 

When you add new item to the project they are added to the end of the list. They are kept in the order that they were added to the project because this order is preserved in the corresponding *.ssmssqlproj file. To change this order, close the project/solution, then locate the *.ssmssqlproj file and edit it with Notepad or your favorite XML editor (always make a backup first!). Reorder the FileNode elements along with their children to reorder the items appearance in the Solution Explorer.

RBarryYoung
+1  A: 

Here's the solution I took. Up votes for the recommendation of the source code, however I don't have .NET installed here, so I had to go for a manual approach.

  1. finish working on any project or solution files you have checked out, and check these edits in.
  2. get latest version on everything in the solution.
  3. Check everything out
  4. Backup the whole folder structure
  5. open the .ssmssqlproj file in notepad
  6. maximise notepad full screen and turn word-wrapping off
  7. edit the .ssmssqlproj file, reordering the XML nodes in the required order
  8. save the .ssmssqlproj file
  9. check everything back in.

That seems to have fixed my issue.

cometbill
+1  A: 

The stored procedure listed in the following post can do it as well: http://beyondrelational.com/blogs/jacob/archive/2009/08/22/xquery-lab-48-sorting-query-files-in-sql-server-management-studio-ssms-solution-project.aspx