CASE WHEN .. THEN .. ELSE .. END

  • HI All,

    How does a case statement determine which datatype to use?

    I have a feeling it's got to do with Data Type Precedence is this correct?

    Here is a Precedence list:

    http://msdn.microsoft.com/en-us/library/ms190309.aspx

    Thanks

    Chris

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • ooops

    Sorry lazy me, I check BOL, and it seems

    Result Types

    Returns the highest precedence type from the set of types in result_expressions and the optional else_result_expression. For more information, see Data Type Precedence (Transact-SQL).

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • best to cast all expressions to a common type or cast the entire case statement to the desired type.

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

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