bit type : default to '0' instead of NULL

Viewed 111677

By default sql server assigns boolean fields a NULL value. How can I tell it to use '0' as default? I tried setting the default value to ((0)) but it still persists on the NULL.

5 Answers

Please add suffix WITH VALUES, like the following. It works well:

ALTER TABLE (your table) 
ADD (your column) [bit] NULL DEFAULT 1 WITH VALUES;
ALTER TABLE (table name) ADD (column name) BIT NOT NULL DEFAULT 0;
Related