• Gillian_Pappas2002 (12/12/2013)


    Thank you very much Kurt. That is awesome and is exactly what they are looking for.

    Pardon my ignorance but I have never seen ;with before, and are you using alias's? Not exactly sure how to plug that in correctly into my .sp.

    Thanks again for your patience and extreme help.

    Gillian

    WITH is the first part of a common table expression (cte). In actuality the ;with is a little odd. Many people got in the habit of starting a line of code like that but the truth is that a cte requires the previous line of code to end with a semicolon. Remember that the semicolon is a line terminator, not a line beginninator (credit to Lynn Pettis for the phrasing). 😀

    In essence it is like an inline view. Check them out on BOL here. http://msdn.microsoft.com/en-us/library/ms175972.aspx

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/