Problem with LIKE in SQL 2000

  • Hi,

    Alas, still waiting to migrate to SQL 2008, where it may not be a problem, so please excuse my posting here 🙂

    I've just been alerted to a problem with one of my scripts that fails when doing a query in SQL 2000.

    The varchar value it's looking for is e.g. '123456AAYM', but the query "... Like '123456A%'" fails, returning no rows !

    Both "... Like '123456%'" and "... Like '123456AA%'" works, returning multiple rows as expected. Including the sought after value.

    Please, can anyone shed any light on this completely unexpected and baffling behaviour ?

    TIA

    --

    Lars I Nielsen

    GIS and DB Intergrator

    Denmark

  • Perhaps I should add, that the query is into a view, not a table.

    And that the database in question has a default collation named "Danish_Norwegian_CI_AS".

    I don't know whether this makes a difference or not.

  • Hi again,

    Solved it myself, sort of ...

    Adding "Collate SQL_Latin1_General_CP437_CI_AS" to the query solved the problem.

    I.e. "... MyColumn Collate SQL_Latin1_General_CP437_CI_AI Like '123456A%'" returns the expected rows.

    It also works when specifying the collation directly on the view field.

    Oh well, lots of views to check, I fear :crying:

    --

    Lars I Nielsen

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply