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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 user defined type, one of three string values?

Author  Topic 

jcmoon
Starting Member

1 Post

Posted - 2011-10-13 : 12:25:30
Hi!

I'm new to SQL server 2008, and database design in general....I want to design a table, having one of the fields validate on one of three string values: opt, req, or na

is there a way to define a user defined type, which only excepts one of those values?

thanks!

james moon

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-13 : 12:27:58
you need to add a check constraint on it like

ALTER TABLE <table name> ADD CONSTRAINT Chk_<Columnname> CHECK (Column IN ('opt','req','na'))

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -