Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们的一个 SQL 表中有一个 uniqueidentifier 列,它被设置为主键。由于各种原因,我们不希望它由 SQL 自动生成。
我希望能够在此列上添加一个约束以禁止值 '00000000-0000-0000-0000-000000000000'
这很容易实现吗?
alter table YourTable add constraint CHK_YourTable_GUID check (guid <> '00000000-0000-0000-0000-000000000000')
SQL Fiddle 的示例。