all groups > sql server programming > december 2005 >
You're in the

sql server programming

group:

why is it giving output ?



why is it giving output ? Manish Sukhija
12/21/2005 10:34:01 PM
sql server programming: Hi,
when i run this query
select * from personal where phone > '40-8496-7223'
it works fine, eventhough i declared phone as
varchar type, it should not operate on > operator.
Re: why is it giving output ? Chris2
12/21/2005 11:47:51 PM

"Manish Sukhija" <ManishSukhija@discussions.microsoft.com> wrote in
message news:C4ABE18E-6C0D-4B91-9F7E-30454D398737@microsoft.com...
[quoted text, click to view]

Manish Sukhija,

May I ask what makes you think that the > operator can't be used to
compare a varchar column to a string literal?


Sincerely,

Chris O.

Re: why is it giving output ? Raymond D'Anjou
12/22/2005 8:44:46 AM
[quoted text, click to view]

I'd just like to know WHY you would run such a query?

Re: why is it giving output ? Uri Dimant
12/22/2005 8:56:02 AM
Hi ,Manish

I think that SQL Server internally convert a first character to the INT and
compare them



IF '130-0074321'>'211-4988260'
PRINT 'Yes'
ELSE
PRINT 'No'


In above example SQL Server is comparinmg 1 (first character) from the
first parameter to the 2 (first character) from the second parameter and
result is NO





[quoted text, click to view]

Re: why is it giving output ? Trey Walpole
12/22/2005 11:08:31 AM
sure it should.

how could you ORDER BY a [var]char column if one string couldn't be >
another?


[quoted text, click to view]
Re: why is it giving output ? Roji. P. Thomas
12/22/2005 3:50:57 PM
Uri,

There is no implicit conversion. The > operator works on the (ASCII ?)
value of the characters.

IF 'AAAC'>'AAAB'
PRINT 'Yes'
ELSE
PRINT 'No'

--
Roji. P. Thomas
Net Asset Management
http://toponewithties.blogspot.com


[quoted text, click to view]

AddThis Social Bookmark Button