Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Sorting order

Author  Topic 

amsqlguy
Yak Posting Veteran

89 Posts

Posted - 2012-03-05 : 12:23:17
Guys,

Is it possible to sort in the following order for a column which starts special characters and alpha numeric characters.

!
"
$
?
@
^
{
>
1
2
3
4
5
6
7
8
9
A
B
C
D

Thanks

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-05 : 12:27:44
Sure...


SELECT * FROM (
SELECT '!'AS [CHAR] UNION ALL
SELECT '"'AS [CHAR] UNION ALL
SELECT '$'AS [CHAR] UNION ALL
SELECT '?'AS [CHAR] UNION ALL
SELECT '@'AS [CHAR] UNION ALL
SELECT '^'AS [CHAR] UNION ALL
SELECT '{'AS [CHAR] UNION ALL
SELECT '>'AS [CHAR] UNION ALL
SELECT '1'AS [CHAR] UNION ALL
SELECT '2'AS [CHAR] UNION ALL
SELECT '3'AS [CHAR] UNION ALL
SELECT '4'AS [CHAR] UNION ALL
SELECT '5'AS [CHAR] UNION ALL
SELECT '6'AS [CHAR] UNION ALL
SELECT '7'AS [CHAR] UNION ALL
SELECT '8'AS [CHAR] UNION ALL
SELECT '9'AS [CHAR] UNION ALL
SELECT 'A'AS [CHAR] UNION ALL
SELECT 'B'AS [CHAR] UNION ALL
SELECT 'C'AS [CHAR] UNION ALL
SELECT 'D'
) AS XXX
ORDER BY [CHAR]


What's the question again?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -