Thank you Paul.
This field is not Date type field, so I cannot return its value as Date.
SP doesn't give any problem, but spead. When the recordset is created
initially it takes sometimes up to 10 seconds. Then any change of Sort is
done within a portion of a second.
So I was looking for the way to sort the recordset, not to repopulate it.
vovan
> ¤ I have a stored procedure with Order By as:
> ¤ CASE WHEN CAST((Left(dbo.[Partial].PartialNumber, 2)) AS int)<50
[quoted text clipped - 45 lines]
> ~~~~
> Microsoft MVP (Visual Basic)
Jeff Johnson - 27 Mar 2007 15:45 GMT
> This field is not Date type field, so I cannot return its value as Date.
> SP doesn't give any problem, but spead. When the recordset is created
> initially it takes sometimes up to 10 seconds. Then any change of Sort is
> done within a portion of a second.
> So I was looking for the way to sort the recordset, not to repopulate it.
It's not going to happen. YOU know that 99 < 01, but there is absolutely no
way to tell the Recordset that. You'd have to implement your own sorting
through code, plain and simple.
Paul Clement - 27 Mar 2007 19:11 GMT
¤ Thank you Paul.
¤ This field is not Date type field, so I cannot return its value as Date.
¤ SP doesn't give any problem, but spead. When the recordset is created
¤ initially it takes sometimes up to 10 seconds. Then any change of Sort is
¤ done within a portion of a second.
¤ So I was looking for the way to sort the recordset, not to repopulate it.
¤
Ditto what Jeff said. Sort operates on the data already present in the Recordset, and what you have
for that column is not suitable for a proper date sort.
Paul
~~~~
Microsoft MVP (Visual Basic)
Alexander Mueller - 31 Mar 2007 22:27 GMT
27.03.2007 17:15, vovan schrieb:
> Thank you Paul.
> This field is not Date type field, so I cannot return its value as Date.
> SP doesn't give any problem, but spead. When the recordset is created
> initially it takes sometimes up to 10 seconds. Then any change of Sort is
> done within a portion of a second.
> So I was looking for the way to sort the recordset, not to repopulate it.
If you'd query it as an UNION you'd get rid of the sluggish CAST/CASE WHEN
statement. Consider somthing like:
Select '19' || dbo.[Partial].PartialNumber As PN From ....
WHERE dbo.[Partial].PartialNumber LIKE '9%'
UNION
Select '20' || dbo.[Partial].PartialNumber As PN From ....
WHERE dbo.[Partial].PartialNumber LIKE '0%'
ORDER BY PN
I have no T-SQL expertise at all so I do not if || is supported
for string-concatenation in T-SQL, and if the other syntax-details
match, afaik in some RDBMS ORDER BY is only valid as part
of the first major SELECT in a UNION, not at the end,
so try it out.
MfG,
Alex
CASE WHEN CAST((Left(dbo.[Partial].PartialNumber, 2)) AS int)<50
>> then
>> € CAST(1 AS varchar)+(dbo.[Partial].PartialNumber)
>> € else
>> € CAST(0 AS varchar)+(dbo.[Partial].PartialNumber)
>> € end
>> € I have a stored procedure with Order By as:
>> € CASE WHEN CAST((Left(dbo.[Partial].PartialNumber, 2)) AS int)<50
[quoted text clipped - 5 lines]
>> €
>> € Why do I use this? It's because PartialNumber field contains values