|
lazerath
Constraint Violating Yak Guru
343 Posts |
Posted - 2010-05-20 : 14:57:13
|
| Actually, the sample number provided isn't really a decimal. It's a huge whole number. This is what it looks like in "regular" notation:4,111,111,111,111,110,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000The maximum value you can put in a DECIMAL(38,0) is:99,999,999,999,999,999,999,999,999,999,999,999,999The maximum storable in a BIGINT is:9,223,372,036,854,775,807It is possible to use a function similar to the ones I created here:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=95322To test the value before conversion and supply a default if it is outside the bounds of what DECIMAL can provide:declare @f floatset @f = 4.11111111111111E+165SELECT CONVERT(DECIMAL(38,0),CASE dbo.udfIsValidDECIMAL(@f,38,0) WHEN 1 THEN @f ELSE NULL END)Unfortunately, my function doesn't support float because it rejects scientific notation. You would first have to expand the float to regular notation before passing it into the function. |
 |
|