Case expressions

  • Hi everyone,

    Few of the queries that I'm watching now have 15-20 case expressions. Just curious if case is resource intensive and if there's an alternative approach.

    Thank you.

  • It depends , case allows for conditional logic based on the data within the returned result set and therefore can make some queries really simple to code and effective. The usage will depend on the logic within which it is used. A possible alternative to the case statement would be Join to a table which contains the lookup value and the alternative. but this approach would not work for a majority of cases such as performing calculations etc.

    Jayanth Kurup[/url]

  • I recently ran into this issue: "SQL Server allows for only 10 levels of nesting in CASE expressions" (http://msdn.microsoft.com/en-us/library/ms181765.aspx).

    I've only had issues with this in scripts that run across linked servers but something to keep in mind.

    _____________________________________________________________________
    - Nate

    @nate_hughes

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply