Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 851
  • Last Modified:

SQL Server Data Type to use for Whole Number

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
hojohappy
Asked:
hojohappy
  • 2
  • 2
4 Solutions
 
Aneesh RetnakaranDatabase AdministratorCommented:
you can use int, and for fromating purpose you can convert them
0
 
Surendra NathCommented:
yes it is good to INT, if the amounts are too big then you can use BIGINT.
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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
 
Aneesh RetnakaranDatabase AdministratorCommented:
if you are using sql server 2012, you can use the FORMAT statement to format the results

select FORMAT(10000, '###,###,###,###')
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now