I am need to convert a value in to decimal.Before that I am checking a condition.I want to eliminate the decimal values if @tbt=1.
Eg if @tbt=1 then 15
if @tbt=0 then 15.233
declare @tbt int =1
1) select
CASE WHEN @tbt=1 THEN CONVERT(DECIMAL(24,0),15.23335)
ELSE CONVERT(DECIMAL(24,3),15.23335) END
2) select
CASE WHEN @tbt=1 THEN '1'
ELSE '2' END
The first Query will returns 15.000.
1. Is it possible to get 15?
2. If CONVERT(DECIMAL(24,0),15.23335) returns 15.then why it is coming 15.000 in the query.
For checking I used another query and it will prints 2.
Thanks
you could use your current solution and add additional cast to Varchar(30) on both.