February 3, 2012 at 2:58 am
Hi ALL.
Convert the Int value to Decimal
Select Case When 1 = 1 Then Convert(decimal(10,2),100) Else Convert(decimal(10,3),100) End.
If Case Condition is True
Result Should be - 100.00
Else
Result Should be - 100.000
If is possible to get the same result value with different dicimel places.
Regards,
Sathish.S
February 3, 2012 at 3:08 am
Case statement can only have one data type that it returns. Even if the case statement has few data types that it can return, it will return a data type that all the cases can be converted to. If some of the data types are not compatibles, you'll get an error. In the example that you wrote, you should get decimal(10,3) because decimal(10,2) can be converted to decimal(10,3), but the opposite can not happen.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply