Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Which Datatype should I use?? Expand / Collapse
Author
Message
Posted Wednesday, December 11, 2013 3:37 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 06, 2014 5:06 AM
Points: 9, Visits: 25
I want change the data type of my Table. It has a Weight column with following description

[Weight] [numeric](9, 4) NOT NULL,

Now I want to allow 99999.99999 which data type should I use?? Please help its urgent

Post #1521798
Posted Wednesday, December 11, 2013 3:48 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 3:45 AM
Points: 390, Visits: 700
DECIMAL(10,5)




I'm on LinkedIn
Post #1521803
Posted Wednesday, December 11, 2013 3:49 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:51 AM
Points: 14,788, Visits: 27,264
If you understand that NUMERIC is a precision and then a scale, then you'd know that you need NUMERIC(10,5). Read up on it here. I'd also suggest, instead of NUMERIC, use DECIMAL. There's no real difference, just clarity and compliance with ISO standards.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1521806
Posted Wednesday, December 11, 2013 3:53 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 3:45 AM
Points: 390, Visits: 700
Grant Fritchey (12/11/2013)
If you understand that NUMERIC is a precision and then a scale, then you'd know that you need NUMERIC(10,5). Read up on it here. I'd also suggest, instead of NUMERIC, use DECIMAL. There's no real difference, just clarity and compliance with ISO standards.


Yes, I would have elaborated also but I was eating a sandwich at the time and typing one-handed. It was a nice sandwich though





I'm on LinkedIn
Post #1521808
Posted Wednesday, December 11, 2013 4:06 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:51 AM
Points: 14,788, Visits: 27,264
yayomayn (12/11/2013)
Grant Fritchey (12/11/2013)
If you understand that NUMERIC is a precision and then a scale, then you'd know that you need NUMERIC(10,5). Read up on it here. I'd also suggest, instead of NUMERIC, use DECIMAL. There's no real difference, just clarity and compliance with ISO standards.


Yes, I would have elaborated also but I was eating a sandwich at the time and typing one-handed. It was a nice sandwich though


I can live with that, but next time, share.


----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1521815
Posted Wednesday, December 11, 2013 4:31 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 01, 2014 2:04 AM
Points: 48, Visits: 130
Yes,

DECIMAL(10,5) would be the good choice, as "10" stands for the Total Integer count allowed and the "5" stands for the scale where you can enter the max of .99999

but one drawback is the "0" would be suffixed at all times when there is a space to occupy in the scale.

create table testxxx(numbr decimal(10,5))

insert testxxx(numbr) values(0.9)

select * from testxxx

Result
------
0.90000

whereas the expected might be 0.9
Post #1521825
Posted Wednesday, December 11, 2013 4:34 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 4:08 AM
Points: 41,519, Visits: 34,437
That's a formatting issue that should be dealt with in whatever application is reading this data.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1521828
Posted Wednesday, December 11, 2013 5:06 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:51 AM
Points: 14,788, Visits: 27,264
GilaMonster (12/11/2013)
That's a formatting issue that should be dealt with in whatever application is reading this data.


Absolutely!


----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1521837
Posted Wednesday, December 11, 2013 6:35 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 06, 2014 5:06 AM
Points: 9, Visits: 25
Thank you every one... I have used Decimal (10,5)
Post #1521867
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse