11 November 2026

SQL Data Types and NULL: Choose the Right Column Type

  Asp.Net CS By Example       11 November 2026

Learn SQL data types for beginners: INTEGER, DECIMAL, VARCHAR, DATE, BOOLEAN and NULL. Includes practical table design tips.

Column type mapINTEGERcountDECIMALmoneyVARCHARtextDATEday

Choose a type that matches the data. Use INTEGER for counts, DECIMAL for money, VARCHAR for names, DATE for calendar dates, and NULL when a value is genuinely unknown. NULL is not zero and is not an empty string.

Example

SELECT department, COUNT(*) AS student_count
FROM students
WHERE active = 1
GROUP BY department
ORDER BY student_count DESC;

Try it yourself

  1. Create a small table with five rows.
  2. Run the example and change one clause.
  3. Explain the result in your own words.

Back to the SQL learning path · Reference topic map · Microsoft SQL documentation

logoblog

Thanks for reading SQL Data Types and NULL: Choose the Right Column Type

Previous
« Prev Post

No comments:

Post a Comment

Please do not enter any spam link in the comment box.