marshall marshall - 1 year ago 115
SQL Question

check sql query like enum in mysql

in mysql i'm using enum and display variable with enum_range.
how to display check variable range in sql server if

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download