How to constraint no empty strings on an NVARCHAR column

后端 未结 6 901
悲&欢浪女
悲&欢浪女 2020-12-29 03:36

I add a NOT NULL constraint on my NVARCHAR column so it couldn\'t allow any empty values. but unfortunately SQL Server deals with NULL

6条回答
  •  甜味超标
    2020-12-29 03:44

    • If the value is being assigned a string property you can add logic at the property set method.
    • If you would rather enforce this at the SQL layer then tvanfosson's answer is good.
    • Unfortunately using a trigger is not going to work because a trigger can not affect the record being inserted...

提交回复
热议问题