你能在 SQL 中限制一个 nvarchar(max) 字段吗

Can you Limit an nvarchar(max) field in SQL

我知道这可以在 client/server 中设置,但是有没有办法对 nvarchar(max) 字段设置超过 4000 个字符的字符限制。 IE 20,000 个字符?

正如肖恩暗示的那样:

CREATE TABLE  ImageTable (ImageID INT IDENTITY PRIMARY KEY 
                      ,   ImageBinary VARBINARY(MAX)  )

ALTER TABLE [dbo].ImageTable ADD CONSTRAINT [CX_ImageTable_Size]  
                                    CHECK ( DATALENGTH(ImageBinary) < 19999)

INSERT INTO dbo.ImageTable (ImageBinary ) values (0x0000000000000000001)  
  --  throws error if length is longer than constraint