|
-
Jan 20th, 2002, 12:30 AM
#1
Thread Starter
Addicted Member
Help! Sorting Numbers in Text Field in SQL Server
Hi, I'm converting my database from Access to MSDE SQL 2000.. One problem that I ran acrossing is sorting numbers in a text field. I have to store numbers like 3, 3A, 3B, 4, 5, etc.. Is Access, I used to use:
SELECT * FROM [Item] WHERE CATID = "& CatID & "ORDER BY Val([LotNumber]) DESC, IIf(Val(Right$([LotNumber],1))=0,Right$([LotNumber],1),"""") DESC;"
But when I'm connect to the MSDE SQL database, it complains.. Is there anyway to sort this data the way I need it to?
Thanks
John
-
Jan 20th, 2002, 12:59 AM
#2
Try something like this:
"SELECT * FROM [Item], Val([LotNumber]) AS Sort1, IIf(Val(Right([LotNumber],1))=0,Right([LotNumber],1),'') AS Sort2 WHERE CATID = " & CatID & " ORDER BY Sort1 DESC, Sort2 DESC"
-
Jan 20th, 2002, 01:48 AM
#3
Thread Starter
Addicted Member
Hi, thanks for the reply.. Can't seem to get your SQL query to work.. Does SQL MSDE doesn't like the Val() function? I can't so a simple sort using Val(LotNumber).. It return an error..
Thanks
John
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|