• Phil Parkin (7/31/2013)


    Presumably you mean a global temp table.

    No. Broccoli appears to be talking about a single script, divided into multiple batches. Thus a local temp table would do fine.

    Although it would probably work, it's a bad idea - it would require just as much code as the DATEADD solution, with the added server overhead of having to retrieve the info from disk.[/quote]

    The logic for the expression would be in a single place. If you have a couple of these suckers, and they are decently complex, the temp table is not a bad idea.

    The data would be in cache, but it is true that it would be backed by disk space, so there is some overhead.

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]