• Davebhoy (7/4/2013)


    Hi there

    I'm a novice a at SQL so hopefully this is an easy answer for someone.

    I have a basic view which queries two tables in separate databases with one join on 'client' which also contains a WHERE clause using 'client'.

    When I use a parameter for this column called @client (=@client) the results return almost instantly but when I use the same parameter as a text value (='XX'). It takes 20 seconds to return he same results!

    Any help is appreciated.

    Dave.

    What is the datatype of the column in the underlying table that you're trying to compare to and what is the datatype of @Client? It might simply be a datatype mismatch causing a table scan instead of an index seek. Can't tell for sure because I don't have the schema for your tables, nor the code for your view, nor any information for what @Client actually is.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)