user2121038
user2121038

Reputation: 153

SQL insert row data, trough nulls are not allowed

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?) ?

enter image description here

enter image description here

Upvotes: 0

Views: 40

Answers (1)

Anon
Anon

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

Related Questions