Can SQL Server 2008 do this? Allow only specific values..

One of the great features I like about Intersystems Cache is the ability to only allow specific values for a column. For example, if I have an Integer type column, I can specify to only allow the following values:


That column would only allow those values. Is this possible with SQL Server 2008?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David ToddSenior DBACommented:

One way of doing this in MS SQL of course is adding a foreign key.

Another method is a user-defined type.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
crnghtzAuthor Commented:
Here you go. I have a question for you. If I create a stored procedure, is there a Select Case (like in VB.Net) in TSQL that would allow me to do the same thing?

Select Case @InputValue
 Case "1000"
   Return "1000"
 Case "1001"
   Return "1001"
 Case "1002"
   Return "1002"
 Case "1003"
   Return "1003"
 Case Else
   Return "1000"
End Select
David ToddSenior DBACommented:


The case that is T-SQL is for use inside queries, not a control flow structure.


PS Thanks for the grade and the points
crnghtzAuthor Commented:
Thanks and you're welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.