Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Create enum!

Author  Topic 

joe_bgd
Starting Member

2 Posts

Posted - 2007-02-06 : 10:51:01
hi, i'm new to sql. Any idea how to make enum type in micr. sql server management studio 2005. I need something like this:

field_name char enum ('I', 'J', 'K')


pleaase help me!

nr
SQLTeam MVY

12543 Posts

Posted - 2007-02-06 : 11:03:18
Have a look at datatypes in bol (books on-line).

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-02-06 : 11:11:18
and also take a look at constraints. maybe it'll come in handy.



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

joe_bgd
Starting Member

2 Posts

Posted - 2007-02-06 : 12:05:05
Thanx mates,

i solved it with constraint (actually 2 constraints, since i have two enum-type fields in my table).

I've put following constraints:

CHECK(filed_name_1 in ('I', 'J', 'K'))

and

CHECK(filed_name_2 in ('A', 'B', 'C'))

i hope that's good solution, if someone now better one please inform me.
Cheers!
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-02-06 : 12:24:03
well you can also have udf's as constraints.
so what you could do is have a table with your enum values and to where they belong based on the column name
or something like that and pass the column name to your udf that returns values.



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -