Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
select * from ta where Dept=ALL order by convert(int,DeptNum) ASC
DeptNum has type varchar(50).Thanks
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts
Posted - 2009-04-14 : 14:19:57
[code] where Dept= ' ALL ' order by convert(int,DeptNum) ASC [/code]EDIT: also, you might want to make sure that DeptNum CAN be converted into an INT.[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQL or How to sell Used CarsFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp
Kokkula
Starting Member
41 Posts
Posted - 2009-04-15 : 02:53:32
Hello,For this to achieve DeptNum field should be numeric. Try thisSELECT * FROM TableNameWHERE Dept = 'ALL' AND ISNUMERIC(DeptNum) = 1 ORDER BY CONVERT(INT,DeptNum) ASCHope helpful...Thanks,Pavan