Solved

SQL Server Data Type to use for Whole Number

Posted on 2014-02-05
5
613 Views
Last Modified: 2014-02-05
WHat is the best data type to use for a table column to contain whole numbers?  These are amounts but do not need a decimal so I assuming Integer would be best type to use.  They will be need to be formatted on reports with ","

For example;  45000   or 67000
0
Comment
Question by:hojohappy
  • 2
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 400 total points
ID: 39837181
you can use int, and for fromating purpose you can convert them
0
 
LVL 16

Assisted Solution

by:Surendra Nath
Surendra Nath earned 50 total points
ID: 39837184
yes it is good to INT, if the amounts are too big then you can use BIGINT.
0
 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 50 total points
ID: 39837198
int, bigint, smallint, and tinyint, whichever is the smallest storage size to handle the range of numbers you're dealing with, and on the assumption that there will never be a non-number other than NULL to handle.
0
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 400 total points
ID: 39837200
if you are using sql server 2012, you can use the FORMAT statement to format the results

select FORMAT(10000, '###,###,###,###')
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39837207
>They will be need to be formatted on reports with ","
Recommend you store this in the database as one of the above int types, and let whatever reporting tool you're using handle the thousands-separating commas.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now