Solved

SQL Server Data Type to use for Whole Number

Posted on 2014-02-05
5
714 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

734 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