SQL DataType Negative Decimal

user979331 picture user979331 · Nov 7, 2011 · Viewed 80.7k times · Source

Im inserting Data into a database, they have a decimal and a negative number, is there a way to the DataType Decimal into negative numbers or is there another data type I can use?

Answer

user596075 picture user596075 · Nov 7, 2011

The decimal datatype can store negative numbers as well. So to answer your question, yes you can use the decimal datatype to store negative decimal numbers.

Here is some proof:

create table NegativeDecimal
(
    somedec decimal(10, 4) not null
)
go

insert into negativedecimal
select -12.3
union all
select 16.4
go

select *
from NegativeDecimal

somedec
---------------------------------------
-12.3000
16.4000

(2 row(s) affected)

EDIT: This is provided you are using SQL Server. Please specify your RDBMS.