• sdownen05 (10/31/2011)


    Not a problem, Jeff. Thanks for calling me on that.

    I only want records that end in '_Syteline_HQ_App', so I just did this:

    select left(JobName, patindex('%_[0-9]%', JobName) - 1)

    from #JobName where JobName like '%_Syteline_HQ_App'

    I know it doesn't solve everyone's problem, but it takes care of this one.

    However, I just noticed Ninja's_RGR'us post. That code is much better than mine.

    Thank you all for everything, and I will remember to contribute more. You all have taught me a lot in a short amount of time.

    Steve

    Glad it helped.

    In the best of both worlds you'd both filter the data down as much as possible and protect yourself from the left failing on you. Being able to do both without forcing a table scan is always a good option ;-).

    P.S. It's the same trick when doing avgs => SUM(a) / SUM(b) => Divide by 0 error. However / NULLIF(SUM(b), 0) won't fail on you either.

    Very useful to know :-).