Comparing (var)char fields

2005-04-01 01:24:04 AM
some algorithms are based on having
two sorted queues of items. I pick up one
item from both queues and , based on the
compare result, the procedure flows further.
Sorted queues are easy to obtain by creating
datasets - results of SQL query with ORDER BY
clause. The problem arises when one needs to compare
current records from the two datasets.
If the sort order is based on date or number,
the sort order is the only possible one.
With character fields, however, the sort order
may differ according to the database settings.
Basically what I need is a "compare " function
which, when used for sorting database records,
would yield the same order of records as does
the SQL server when I use the ORDER BY "some character field".
It is clear that simple comaprisons like
"if s1<s2" or
do not work (for obvious reasons)
I know that, in Paradox/BDE there exists a BDE exported
routine that can do that. Does anyone know about
similar solution (apart from having to write a stored procedure)
that would do the same in MS SQL server?