• It's been several years since I've had to work with OPENQUERY but I believe the following will work...

    select <stuff ...>

    from OPENQUERY(Banner_Prod, 'SELECT a.Major

    ,a.FIRSTNAME AS NameFirst

    ,a.MIDDLENAME AS NameMiddle

    ,a.LASTNAME AS NameLast

    ,a.CLASSCODE AS PersonSubType

    FROM fredtrailer.student_Directory_info a'

    ) oq

    WHERE oq.STUD_ID = @STUD_ID

    The only thing that I don't remember is whether or not the external criteria is reflected in the OPENQUERY or if the whole OPENQUERY result set is returned before the criteria is applied. The performance test for that is, of course, simple enough. Give it a try.

    --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)