What is the best practice for creating a yes/no i.e. Boolean field when converting from an access database or in general?
What is the best practice for creating a yes/no i.e. Boolean field when converting from an access database or in general?
In SQL Server Management Studio of Any Version, Use
BITas Data Type
which will provide you with True or False Value options. in case you want to use Only 1 or 0 then you can use this method:
CREATE TABLE SampleBit(
bar int NOT NULL CONSTRAINT CK_foo_bar CHECK (bar IN (-1, 0, 1))
)
But I will strictly advise BIT as The BEST Option. Hope fully it's help someone.
If you are using Postgres, the BIT type won't support it. So, you have to use INT for storing boolean type. In that case, you can assume 0 as false and 1 as true.
[ColumnName] INT NULL DEFAULT 0