• One way to assign more than one value to a variable is to use a table variable.

    But the major issue with your code is slightly different: you're using the very same question again and again to assign a single variable.

    Here's a way to assign values to more than one variable with one SELECT:

    SELECT @EMAIL = email,

    @fname = fname,

    @month_last_taken =coursename_new

    FROM (

    select vw_sch.person_number as id, vw_sch.fname,vw_sch.email

    , vw_sch.manager_name,vw_sch.coursename_new, vw_sch.mgr_email

    from

    TD_EMPLOYEE_COURSE_SCHEDULE_VW AS VW_SCH

    LEFT join TD_EMPLOYEE_COURSE_HIST_VW_xx AS VW_HIS

    ON VW_HIS.id=VW_SCH.id

    where month_number_due=7

    and (month_last_taken_num is null or month_last_taken_num<7)

    and vw_sch.person_number=@EMP_ID



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]