SQL Server equivalent to MySQL enum data type? SQL Server equivalent to MySQL enum data type? sql-server sql-server

SQL Server equivalent to MySQL enum data type?


It doesn't. There's a vague equivalent:

mycol VARCHAR(10) NOT NULL CHECK (mycol IN('Useful', 'Useless', 'Unknown'))


The best solution I've found in this is to create a lookup table with the possible values as a primary key, and create a foreign key to the lookup table.


IMHO Lookup tables is the way to go, with referential integrity. But only if you avoid "Evil Magic Numbers" by following an example such as this one:Generate enum from a database lookup table using T4

Have Fun!