No, it does not work that way. A CASE expression, like any other expression, in SQL Server has a static data type. That is, you cannot have an expression that returns different data types depending on some argument.
Whenever there is a mix of data types in an expression, SQL Server will apply its data-type precedence, and convert the type with lower precedence to the type in the expression with the highest precedence. Provided, that is, an implicit conversion exists.
So what you are asking for is not possible. If you give us more details about your predicament, we might be able to help you.
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
No comments:
Post a Comment