Reputation: 153
I created a simple database in sql 2012 where I didnt allow to store null data, I checked out my program and I see that it still save empty row :( Is there option that can help me prevent save null in db (and why turning off "allow null" didnt stop it?) ?
Upvotes: 0
Views: 40
Reputation: 10918
You want a CHECK Constraint. This will throw an error when a statement attempts to put data in a field that doesn't match the criteria.
ALTER TABLE UserInfo ADD CONSTRAINT CK_UserInfo_Login CHECK (Login <> '')
Upvotes: 1