|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
why is it giving output ?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. what could be reason 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 Show quote "Manish Sukhija" <ManishSukh***@discussions.microsoft.com> wrote in message news:C4ABE18E-6C0D-4B91-9F7E-30454D398737@microsoft.com... > 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. > what could be reason Uri,
There is no implicit conversion. The > operator works on the (ASCII ?) value of the characters. IF 'AAAC'>'AAAB' PRINT 'Yes' ELSE PRINT 'No' Show quote "Uri Dimant" <u***@iscar.co.il> wrote in message news:eTjC9SsBGHA.916@TK2MSFTNGP10.phx.gbl... > 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 > > > > > > "Manish Sukhija" <ManishSukh***@discussions.microsoft.com> wrote in > message news:C4ABE18E-6C0D-4B91-9F7E-30454D398737@microsoft.com... >> 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. >> what could be reason > > "Manish Sukhija" <ManishSukh***@discussions.microsoft.com> wrote in Manish Sukhija,message news:C4ABE18E-6C0D-4B91-9F7E-30454D398737@microsoft.com... > 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. > what could be reason 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. "Manish Sukhija" <ManishSukh***@discussions.microsoft.com> wrote in message I'd just like to know WHY you would run such a query?news:C4ABE18E-6C0D-4B91-9F7E-30454D398737@microsoft.com... > 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. > what could be reason sure it should.
how could you ORDER BY a [var]char column if one string couldn't be > another? Manish Sukhija wrote: Show quote > 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. > what could be reason |
|||||||||||||||||||||||