If I set a Record in Sql with a Default
constraint like
[Publicbit] BIT DEFAULT ((0)),
Do I need to set the NULL/NOTNULL
Constraint?
Edit: I am using a boolean but please expand your answer to other datatypes.
You never need the Null constraints, but the default value won't guard your table against explicit NULL's. So you should use a NOT NULL constraint if you want to enforce this condition.
use tempdb
go
CREATE TABLE example
(
id BIT DEFAULT (0)
)
INSERT example (id) VALUES (null)
SELECT * FROM example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With