marshall
marshall

Reputation: 74

Check SQL query like enum in MySQL

In MySQL I'm using enum and display variable with enum_range. How can I display check variable range in SQL Server if

roles VARCHAR(10) NOT NULL CHECK (roles IN('Admin', 'Staff', 'User'))

Upvotes: 0

Views: 973

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270051

If you want to see the values, don't use either enum or check. Use foreign key constraints:

create table Roles (
    RoleId int identity primary key,
    RoleName varchar(255)
);

insert into Roles(RoleName)
    values ('Admin'), ('Staff'), ('User');

create table . . . (
    . . .
    RoleId int references Roles(RoleId),
    . . .
);

The shortcuts you want to use just get in the way of using the capabilities of the database.

Upvotes: 2

Related Questions