对列的约束以设置可能值的限制

Constraint on column to set limit of possible values

我需要对列进行约束,使其只能包含以下范围的值

Allowed values: between 1 and 10
Column Data Type: tinyint
DBMS or Docker Image: Microsoft SQL Server - mcr.microsoft.com/mssql/server:2019-latest

我想应该是接近这个的东西

ALTER TABLE [dbo].[Projects]
ADD CONSTRAINT chk_val_limit CHECK (Priority in (between 1 and 10))
GO

你可以试试这个!

ALTER TABLE [dbo].[Projects]
ADD CONSTRAINT chk_val_limit CHECK (ColumnName > 1 AND ColumnName < 10)
GO