Thanks for all the assistance with the time issue I was having. It looks like I can make the last code work somehow. I'll have to figure out how to incorporate it in, but I think I can probably manage that.
Here's my next question! I have a field in my source table that contains a range of values, separated by a dash. I need to parse this out into two separate destination table fields. The lengths before and after the dash will vary, so I need to be able to read up to the character, then from the other side of the character. Any suggestions on parsing? Books on line has not provided me with the answer (yet).
For example:
0.1-3.7 needs to be 0.1 (Field1) and 3.7 (Field2)
12.5-27
100-199
Thanks! This board has been extremely helpful for me (the pseudo-DBA).
Dirkcheckout CHARINDEX and PATINDEX either one of these should work for you.|||PATINDEX works perfectly for what I need.
Thanks again!
Dirk
Showing posts with label figure. Show all posts
Showing posts with label figure. Show all posts
Wednesday, March 28, 2012
Wednesday, March 21, 2012
odd order by behaviour
Might be out to lunch, but I can't figure why this is being ordered the way it is:
But I can't tell you intelligently why that works.
SELECT '1' as t
UNION ALL
SELECT 'A' as t
union all
SELECT '['as t
ORDER BY t
I'd expect it to be 1, A, [ but instead it's [, 1, A [ is ascii 91 which is greater than both 1 and A, so why does it come first?
KarlWell, I can tell you that it's related to collation. And I can also tell you that this will get you the results you expect:
SELECT t FROM
(
SELECT '1' as t
UNION ALL
SELECT 'A' as t
union all
SELECT '['as t
) AS A
ORDER BY t collate SQL_Latin1_General_Cp437_BIN
But I can't tell you intelligently why that works.
Terri|||some collations would actually place a "y" towards the beginning of the alphabet...
its not always tied to the ascii codesql
Subscribe to:
Posts (Atom)