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:

1000
1001
1002
1003

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

Thanks
crnghtzAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
David ToddConnect With a Mentor Senior DBACommented:
Hi,

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

Another method is a user-defined type.
http://msdn2.microsoft.com/en-us/library/ms175007.aspx

HTH
  David
0
 
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
0
 
David ToddSenior DBACommented:
Hi,

No.

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

Cheers
  David

PS Thanks for the grade and the points
0
 
crnghtzAuthor Commented:
Thanks and you're welcome.
0
All Courses

From novice to tech pro — start learning today.