• Sarah Wagner (4/4/2014)


    Try this...

    SELECTpd.year,

    pd.period,

    pd.startdate,

    df.projectnumber,

    df.startdate_contract,

    df.enddate_contract,

    MONTH(df.startdate_contract) AS month

    FROMperdat pd (NOLOCK)

    LEFT OUTER JOIN ProjectDateFields df (NOLOCK) ON df.startdate_contract BETWEEN pd.startdate AND pd.enddate

    and df.projectnumber = 'CR1003753'

    Or try it without the NOLOCK hints which will only make your queries return inconsistent information (you can have either missing rows or duplicate rows).

    Check the following articles on this hint.

    http://blogs.msdn.com/b/davidlean/archive/2009/04/06/sql-server-nolock-hint-other-poor-ideas.aspx

    http://sqlblogcasts.com/blogs/tonyrogerson/archive/2006/11/10/1280.aspx

    http://www.jasonstrate.com/2012/06/the-side-effect-of-nolock/

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2