Click here to Skip to main content
15,937,779 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was trying to create a new table. I need to add a column name Status (^ Active/Inactive). I am confused which data type should I select!

What I have tried:

I did varchar. Am I correct? if not what would be the correct datatype.
Updated 8-Mar-21 8:58am

Sure ... "status" being either active or inactive (two values of potential status value ... 0 = inactive, 1 = active (to be typical)).

This is what I call a "flag" (from QBASIC days) which is the same thing as True or False.

Look up Boolean operator somewhere (your choice of search engine).

varchar is typically a string value but you could use it in a case mode ("
zero" or "one").

I'm becoming too verbose about this so; yeah do whatever (and use the BOL as reference; that always helps because it has examples).

Now that I think about it, there's a datatype in TSQL called boole isn't there?
Share this answer
For SQL Server and for a simple On/Off, Yes/No, Active/Inactive I might use bit - bit (Transact-SQL) - SQL Server | Microsoft Docs[^]
I always question myself when I limit something like this so I would possibly use a char(1) in case some one comes along with something like a "Pending" status (yes I've been caught out before)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900