View Single Post
Old 10-14-2005, 14:04   #2 (permalink)
Alan Little
Civilians

 
Default Re: SQL Server: Getting numbers in (right) order

Carved in mystic runes upon the very living rock, the last words of
Dylan Parry of alt.www.webmaster make plain:

> I have a database full of documents and each section within a document
> is given an ID like "1.0", "1.1", "1.2" and so on. The datatype is
> varchar (I wasn't sure if a better type exists?).
>
> Now this is fine until I get to "1.10" which is then logically between
> "1.1" and "1.2" but obviously, in the document it should be after
> "1.9". Is there any way I can retrieve data from the database using
> this sort of /logical to me, but not to a computer/ manner?


If SQL Server has the CAST() function and the DECIMAL type, you could
try that:

order by cast(id as DECIMAL);

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
  Reply With Quote
 
Page generated in 0.65018 seconds with 14 queries