BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
Whether you're creating tables in SQL Server, using SQL variables or passing parameters to stored procedures, you'll need to understand what the possible data types that you can use are.
- Data Types in T-SQL for SQL Server (this blog)
- Text Data Types in T-SQL
- Number Data Types in T-SQL
- Date and Time Data Types in SQL
- Logical, Boolean, Yes/No or Bit Data Types in SQL
- Converting between Data Types
Posted by Andy Brown on 05 October 2012
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Data Types in T-SQL for SQL Server
Whether you're creating tables, passing data to stored procedures or working with variables, you'll need to know what sorts of data SQL Server can work with.
You'll also need to know how to convert between data types, and this is covered at the end of this blog.
The Mickey Mouse Guide to SQL Data Types
If you want a quick reference, you can't go far wrong with choosing between these data types (the rest of this blogs gives the full Monty on what's going on):
|What you're storing||Use||Notes|
|Any string of text||varchar(MAX)||The string of text does have a theoretical maximum limit of 2,147,483,647 characters. That's a LOT of text!|
|Any whole number||int||Again, this has a theoretical maximum value of 2,147,483,647. This is a large number.|
|Any other number||float||This can hold virtuallly any number you can conceive of, from the tiniest fraction to the number of atoms in the Universe.|
|Any date||date||Holds any date between 1st January in 1AD to 31st December 9999!|
|Any logical (yes/no) value||bit||A bit is either on or off (0 corresponds to False, and 1 to True).|
|A calculation||N/A||Computed columns are covered in this separate blog.|
For those who want to know more than this, the rest of this blog gives a fuller picture (it's still not the whole story though).