4

Currently SQL Server 2016 CTP 3 and later releases support NVARCHAR(max) fields with JSON content. However since the type NVARCHAR(max) is totally free-form, there is no constraint on these fields.

Can I declare a constraint that prevents insertion of a non-null value that is not valid JSON?

0

1 Answer 1

4

Add this constraint:

ALTER TABLE [dbo].[Resource] 
 ADD CONSTRAINT [RESOURCE_ExtJSON_VALID] 
   CHECK ( ISJSON( ExtJSON )> 0 ) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.