Pages

Tuesday, June 11, 2013

Sorting stored procedures by Create Date in Enterprise Manager may not work! (SQL Server 2000)

Here's a puzzler that's just come to our attention: Open up Enterprise Manager (EM), drill down to a database on your SQL Server, and select the Tables node. Now, in the right panel, try sorting the list of tables in ascending and descending order. Works just fine, right? But now select the Stored Procedures node and try the same thing. Look closely. If your system is like ours, it simply doesn't work at all! Despite the fact that EM claims to be sorting by the Create Date column, we noticed that the dates are all out of order! And the same is true for Views. And User Defined Functions. And Rules.


In fact, the only collection we saw sorting correctly was Tables. And it gets weirder: Continue clicking the column header and you'll notice that the sort order is *different* every time! EM is basically just randomizing the list (or at least, it looks random to those of us whose native language isn't binary).

Why is this? As yet, we have no answer to this mystery--if anybody reading this *does* know, please drop us a line at sql_editor@elementk.com.

In the meantime, if you need to sort your stored procedures by their creation date, there's another way: using Query Analyzer. The following query will accomplish the task:

SELECT *
FROM sysobjects
WHERE xtype = 'P'
/* Change the xtype for other database objects */
ORDER BY create DESC


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.