|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 12, 2013 6:04 AM
Points: 47,
Visits: 17
|
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 12:39 PM
Points: 5,103,
Visits: 20,220
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Saturday, May 18, 2013 6:46 PM
Points: 1,074,
Visits: 1,076
|
|
cheeky ...
didn't occur a doubt on the 0  though I had a doubt over
select isnull ( convert (char(3),1.0/9) ,'*') -- or
select isnull ( convert (char(3),1/9.0) ,'*')
and it clears out as it does throws an error
Msg 8115, Level 16, State 5, Line 1 Arithmetic overflow error converting numeric to data type varchar.
When Implicit conversion occurs , it gives out the output with default precision of 18,6..
so 1.0/9 is 0.111111..
Select select isnull ( convert (char(8),1.0/9) ,'*')
anything less than 8 would have the arithmetic overflow error for this scenario :D
Nice question , though ...
Thanks for the question ..
~ demonfox ___________________________________________________________________ Wondering what I would do next , when I am done with this one
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Yesterday @ 6:02 AM
Points: 766,
Visits: 451
|
|
Nice question..
-- Dineshbabu Desire to learn new things..
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: 2 days ago @ 8:24 AM
Points: 1,176,
Visits: 1,253
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Sunday, May 19, 2013 11:16 PM
Points: 1,061,
Visits: 1,151
|
|
demonfox (3/14/2013)
cheeky ... didn't occur a doubt on the 0  though I had a doubt over select isnull ( convert (char(3),1.0/9) ,'*') -- or
select isnull ( convert (char(3),1/9.0) ,'*')
and it clears out as it does throws an error Msg 8115, Level 16, State 5, Line 1 Arithmetic overflow error converting numeric to data type varchar. thanks for the explanation  When Implicit conversion occurs , it gives out the output with default precision of 18,6.. so 1.0/9 is 0.111111.. Select select isnull ( convert (char(8),1.0/9) ,'*')
anything less than 8 would have the arithmetic overflow error for this scenario :D Nice question , though ... Thanks for the question ..
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 7:51 AM
Points: 1,085,
Visits: 1,166
|
|
Really a nice and good question.
one more thing apart from this question. if you set ARITHABORT OFF and then execute below code, it will give output as "*" due to insufficient char length. and if you set char length more than 7, it will give "0.111111".
It denotes that we need to provide an insufficient length whenever we convert values in char or varchar.
SET ARITHABORT OFF select isnull ( convert (char(3),1.0/9) ,'*')
Keep Learning - Keep Growing !!! http://growwithsql.blogspot.in
Thanks Vinay Kumar
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Sunday, May 19, 2013 11:16 PM
Points: 1,061,
Visits: 1,151
|
|
Danny Ocean (3/15/2013) Really a nice and good question.
one more thing apart from this question. if you set ARITHABORT OFF and then execute below code, it will give output as "*" due to insufficient char length. and if you set char length more than 7, it will give "0.111111".
It denotes that we need to provide an insufficient length whenever we convert values in char or varchar.
SET ARITHABORT OFF select isnull ( convert (char(3),1.0/9) ,'*')
Thanks Vinay for this...
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 7:51 AM
Points: 1,085,
Visits: 1,166
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Sunday, May 19, 2013 11:16 PM
Points: 1,061,
Visits: 1,151
|
|
Danny Ocean (3/15/2013) Really a nice and good question.
one more thing apart from this question. if you set ARITHABORT OFF and then execute below code, it will give output as "*" due to insufficient char length. and if you set char length more than 7, it will give "0.111111".
It denotes that we need to provide an insufficient length whenever we convert values in char or varchar.
SET ARITHABORT OFF select isnull ( convert (char(3),1.0/9) ,'*')
Vinay, I tried with ARITHABORT OFF but still I am getting same error "Arithmetic overflow error converting numeric to data type varchar." set arithabort off select ISNULL(CONVERT(char(3),1.0/9),'*')
|
|
|
|