在 T-SQL 检查约束中,如何允许特定模式或空字符串

In a T-SQL check constraint, how to allow either a specific pattern or the empty string

我现在有一个 phone 数字模式。我想暂时允许空字符串作为有效值。那是什么模式?这是现有的支票:

( ([fax] like '[1-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9][0-9]'))

如何更改该模式以接受空字符串?

How would that pattern be changed to accept the empty string as well?

你可以直接使用 or:

(   
    [fax] = ''
    or [fax] like '[1-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9][0-9]'
)