• If finding rows by birth month without regard to year or day is something important, it's probably worthwhile to materialize the birth month in the table using a persisted computed column.  Like this....


     CREATE TABLE dbo.birthdays
            (
             cust_id    INTEGER         NOT NULL PRIMARY KEY
            ,cust_fname NVARCHAR(50)    NOT NULL
            ,cust_lname NVARCHAR(50)    NOT NULL
            ,cust_dob   DATETIME        NOT NULL
            ,cust_dobmo AS DATEPART(mm,cust_dob) PERSISTED --<----<<< Added this column    
            )
    ;

    Then the code become trivial for such things.  For example...


    DECLARE @pSomeDate DATETIME = GETDATE(); --Could be a parameter for a Stored Procedure or iTVF

     SELECT *
       FROM dbo.birthdays
      WHERE cust_dobmo = DATEPART(mm,@pSomeDate)
    ;

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