user2437588
user2437588

Reputation:

SQL data type for multiple decimal places

What data type in SQL Server will insert the correct number of decimal places for the number entered into a table. When I try to enter a number like so 6.828.678 into a deciaml or numeric field it says input value was not in the correct format. What data type do i use so that it allows this?

Upvotes: 0

Views: 3328

Answers (1)

Rahul
Rahul

Reputation: 77936

If you are trying to store the data in format 6.828.678 (as in your post) then consider using VARCHAR data type.

You can't store 6.828.678 format data into either deciaml or numeric type field cause they are not valid number format and that's why you are getting the error.

Not sure, but per your comment if you want to SUM and compare the value then store it as INT datatype but before inserting the data make sure to remove the ..

You can use REPLACE() function like CAST(REPLACE('6.828.678','.','') as INT). Hope this helps.

Upvotes: 1

Related Questions