Re: Comparision on Char Column With Alphanumeric Values

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Dejan Sarka (dejan_please_reply_to_newsgroups.sarka_at_avtenta.si)
Date: 11/02/04


Date: Tue, 2 Nov 2004 15:36:18 +0100

I guess there must be some sort order where alfa characters have lower ASCII
number that numbers.

-- 
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com
"Vaibhav" <consultvaibhav@yahoo.com> wrote in message
news:uqIlscOwEHA.356@TK2MSFTNGP10.phx.gbl...
> Thank you for the reponse and you are right the expression would always
> evaluate to false and therfore no records are returned.
>
> But the same type of expressions evalutes to true when executed against a
> IBM-DB2 database ans returns records as required, Why is that ?
>
> Is there any way where the expression as mentioned by you, would evaluate
to
> 'True' in MS-SQL server and thus return records.
>
> TIA
>
>
> "Dejan Sarka" <dejan_please_reply_to_newsgroups.sarka@avtenta.si> wrote in
> message news:OxD9rjKwEHA.4004@tk2msftngp13.phx.gbl...
> > Check your expression again - look at this:
> >
> > IF '43299AAAAAAAA' <= '4329999999999'
> > PRINT 'True'
> > ELSE
> > PRINT 'False'
> >
> > -- 
> > Dejan Sarka, SQL Server MVP
> > Associate Mentor
> > www.SolidQualityLearning.com
> >
> > "Vaibhav" <consultvaibhav@yahoo.com> wrote in message
> > news:OeV6ZIGwEHA.200@TK2MSFTNGP11.phx.gbl...
> >> Hi All
> >>
> >> I am using SQL Server 2000.
> >>
> >> I have a table which a column ID(Char(13)). The column has values
varying
> >> from BBB, AAA, , 432990098C,432990164C, 4329999999999 and so on. When i
> > try
> >> to retrieve records from the
> >> table using a query like
> >>
> >> Select * From myTable Where Id >='43299AAAAAAAA' AND
Id<='4329999999999'
> >>
> >> The query returns 0 records, whereas ideally it should return records
> >> with
> >> values like '432999098C','432990164C' and so on.
> >>
> >> I have tried all the different collations on the table column but with
no
> >> success.
> >>
> >> Can some sql guru help me on this.
> >>
> >> TIA
> >>
> >>
> >
> >
>
>


Relevant Pages

  • Re: TOP Predicate makes a query readonly???
    ... Perhaps you can re-write the query, using ANSI syntax, and see if that fixes ... Tom ... Columnist, SQL Server Professional ... > SQL Server MVP ...
    (microsoft.public.vb.database.ado)
  • Re: Order By in a View
    ... "Delbert Glass" wrote in message ... >> Tibor Karaszi, SQL Server MVP ... > you must include the ORDER BY clause in that query. ...
    (microsoft.public.sqlserver.programming)
  • Re: Clustered Index question
    ... Columnist, SQL Server Professional ... PACKET_CONTRACT,PACKET_TIME resulted in the fastest query. ... > SQL Server MVP ... even though I never query for the primary key column? ...
    (microsoft.public.sqlserver.programming)
  • Re: Could not find stored procedure
    ... To add on to Dejan Sarka post, Simply execute the below query in Query ... > loin is mapped to a specific db user dbo, so SQL Server searches dbo.name ...
    (microsoft.public.sqlserver.server)
  • Re: Multi Dimensional Cases in Time Series
    ... This message does not imply endorsement from Solid Quality Learning, ... >> - in SQL Server, create a linked server to the Analysis Services ... >> Dejan Sarka, SQL Server MVP ...
    (microsoft.public.sqlserver.datamining)