Link to home
Start Free TrialLog in
Avatar of Answer_Me
Answer_MeFlag for India

asked on

Enums in Sql-Server

Hi,
   Can we have enums in sql-server? If not, is there any equivalent of enum in sql server.
I'm working on tsql and need to use enum in a particualar scenario in a stored procedure.
Thanks in Advance
Avatar of sigmacon
sigmacon

SQL server doesn't support enums directly - at least not like MySQL (that's the only place where I know about enums ...), but you can create a column as text and put a check constraint on it:

CREATE TABLE SomeTable (
    SomeEnumColumn varchar(10) not null
        constraint CkSomeEnumColumn check (
            SomeEnumColumn in ('Value1', 'Value2', 'Value3')
        )
)

Hope that helps. If not, please post more specifics about what you are trying to do in the stored proc.
Avatar of Answer_Me

ASKER

This is one of feasible approach i already know but i don't want to go this way. coz there is an overhead of maintaing a table and insertions for this.
ASKER CERTIFIED SOLUTION
Avatar of sigmacon
sigmacon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial