Yep, I'm sorry for the complicated question title but couldn't do better:)
This is a follow-up from my answer to that question:
When doing any kind of computation with a user-defined type, the result seems to lose that user-defined type. (At least sa_describe_query implies so.) That is sometimes inevatible, when the result won't fit in the user-defined domain because the domain range would be to small, e.g. when adding two money values, and the sum requires an additional digit.
In other cases, the result would fit in the domain type, e.g. when limiting a char type to a smaller length with LEFT() or when adding 0 to a numeric type as in
(Note: Casting the computed expression back to the user-defined type as in "cast(cast(1 as money) + 0 as money)" works as expected, i.e. then sa_describe_query returns the user-defined type.)
Is this "losing the user-defined type" in the course of any computation by design? (I realize that a "smarter approach" would be very sophisticated to implement.)
asked 17 Jun '10, 17:32
The result type of a computation - i.e. an expression - is computed by a complicated set of rules and any user-defined type at one (or more) of the leaf nodes in the expression is not known at the root of the expression.
answered 17 Jun '10, 17:54