Do You Want to Learn SQL?

Take our free eight day course, where I'll teach you in simple to understand English all you need to get started learning SQL.

-
DAYS
-
HOURS
-
MINUTES
-
SECONDS

Free Beginners SQL Course!

SQL BIT Data Type

·

·

Use the SQL BIT data type to define columns, variables, and parameters value of 1, 0, or NULL. 

Given their Yes/No nature, designer us the BIT type with flag and indicator columns: 

SQL Bit Type used as Flag (true or falsue) values.

Converting BIT Values 

The string values TRUE and FALSE convert to BIT:  TRUE is converted to 1 and FALSE to 0. 

Converting any non-zero value promotes BIT to 1. 

Examples

Here is SQL to query all employees receiving a salary: 

SELECT NationalIDNumber , JobTitle , SalariedFlag FROM HumanResources.Employee WHERE SalariedFlag = 1;
SELECT NationalIDNumber 
 , JobTitle 
 , SalariedFlag 
FROM HumanResources.Employee 
WHERE SalariedFlag = 1;

Additional Resources 

To learn more about data types, check out these useful resources: 

More from the blog


MySQL PostgreSQL SQLite SQL Server