Solved

SQL Server Data Type to use for Whole Number

Posted on 2014-02-05
5
656 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle DB monitor SW 21 48
SQL Server 2012 r2 - Sum totals 2 23
2016 SQL Licensing 7 40
SQL Error - Query 6 24
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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.

776 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