Reputation: 155
I am working on an to solve a problem that I have a textbox that accepts any type of data but I want to cast the data to decimal(12,9)
or any data type can accept this number as an example 42.56926437219384
here is the problem the user can enter any kind of data like characters or integer
1st case I want to handle if the data entered as integer:
DECLARE @num DECIMAL(12,9) = 444444444444444
SELECT CONVERT(DECIMAL(12,9),@num)
I think if it is characters will handle it in the solution and assign validation for the textbox.
how can I handle the integer part?
Upvotes: 1
Views: 11141
Reputation: 8033
When you specify it as DECIMAL(12,9) this means your number can have up to 12 digits (excluding . ) and out of that 9 digits will be after decimal part. Which means the maximum value that you can store here is 999.999999999.
in your sample scenario above, the number has got 15 integer parts which are too high than the scope of your variable, as you can do either of the following
Upvotes: 4