Does SQL Server have an equivalent to MySQL's ENUM data type?

MySQLMySQLi Database

This works in MySQL version 8.0.12. The syntax is as follows.

create table yourTableName
yourColumnName enum(‘Value1’,Value2’,Value3’,......N)
default Value1’ or Value2 or Value3,..N

Set the enum type in MySQL with the following query.

mysql> create table EnumInMySQL
-> (
-> default 'CREATE'
-> );
Query OK, 0 rows affected (0.60 sec)

The syntax of enum in SQL Server.

create table yourTableName
yourColumnName varchar(100)
CHECK(yourColumnName IN (‘Value1’,Value2’,Value3’,......N))
DEFAULT ‘Value1’ or Value2’ or Value3’,......N

Now the query is as follows for enum in SQL Server.

Published on 11-Jan-2019 16:26:53