'How to order project solution content in SQL Server Management Studio
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 ?
Solution 1:[1]
I just came across this forum post. It doesn't get any simpler.
Just edit the ssmssqlproj file.
The file for my project (SQL Main) is located in "My Documents\SQL Server Management Studio\Projects\SQL Main\SQL Main\SQL Main.ssmssqlproj". Its just an xml file. Change the following line
<LogicalFolder Name="Queries" Type="0" Sorted="true">to
<LogicalFolder Name="Queries" Type="0" Sorted="false">It will revert back to true so you need to repeat this if you make changes. THere is probably a better way Smile
Solution 2:[2]
There is a tool that you can install to sort the contents of a SQL Server Solution project.
See the following reference.
http://web.archive.org/web/20121019155526/http://www.sqldbatips.com/showarticle.asp?ID=78
Please ensure you save your work, before attempting a sort.
Solution 3:[3]
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.
Solution 4:[4]
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
Solution 5:[5]
Please note that the sorting is case-sensitive.
So "B..sql" will come before "a...sql".
Remember to start all your scripts with the same casing (be it lower or upper).
Solution 6:[6]
Another easier (I think) way to edit the ssmssqlprog is to do so with MS XML Notepad 2007. With that I could drag the nodes around to order them. Make a copy of course. 2007 appears to be the latest version and is available at ...
http://www.microsoft.com/en-us/download/details.aspx?id=7973
Solution 7:[7]
Another way to handle this is to start with a new query from Management Studio (not by selecting 'New Query' in the solution).
Save the query file into the solution folder with a good name. Then 'Add Existing Item' into the solution.
It adds with your chosen name, sorted correctly instead of creating the file initially as 'SQLQuery1'.
Maybe not much better, but another option to editing the project file and reopening.
Solution 8:[8]
Building on the previous answer, you can add it as a new query in the solution, and when you are done, just remove it from the solution and then Add existing item to the solution, and select your new query. Doing it this way adds the new query to the correct solution folder for you before you remove and add back in.
Solution 9:[9]
And yet another way... while one of these ways worked for me several times... sometimes it becomes stubborn. Find the location where it is broken. Take a screenshot of the file names. Select all the file names you need to remove before the glitch. in other works, if it sorts a - f and then sorts b - z Remove all the a-f (don't delete them) that occur before the b-z, then save the project. Now add them back in and save the project again. Presto. So far this has worked very well for me and is fairly easy to do.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jrummell |
| Solution 2 | bmla |
| Solution 3 | RBarryYoung |
| Solution 4 | |
| Solution 5 | MauricioRPP |
| Solution 6 | Kevin S |
| Solution 7 | SemiPro-grammer |
| Solution 8 | user3116061 |
| Solution 9 | Peoria Os |
