We are converting a char to numeric (so we can do a sort) and the values being returned are wrong. Most of the time they are fine as in the first example. Here's the syntax: This one is fine: select convert(int,(convert(varbinary(10),rtrim('2003-189807')))) --returns 943274032 select convert(int,(convert(varbinary(10),rtrim('2003-190047')))) --returns 959459380 This one is wacky: select convert(int,(convert(varbinary(20),rtrim('2003-189807')))) --returns 959983671 select convert(int,(convert(varbinary(20),rtrim('2003-190047')))) --returns 808465463 Why would the bottom one line return a value that's lower (then the first example) , when the number we are passing it is higher? Any help or suggesions GREATLY appreciated.
Here is your answer select convert(varbinary(20),rtrim('2003-189807')), datalength(convert(varbinary(20),rtrim('2003-189807'))) select convert(varbinary(20),rtrim('2003-190047')), datalength(convert(varbinary(20),rtrim('2003-190047'))) select convert(varbinary, 959983671), datalength(convert(varbinary, 959983671)) select convert(varbinary, 808465463), datalength(convert(varbinary, 808465463)) Bambola.