SQL Server 2005 Table with validation rule

I have a table in the SQL Server 2005 table, and I want this table to only allow the value of A, B, or C. How would I put in this validation rule to the table.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

jerrypdConnect With a Mentor Commented:
you can do it with a constraint...
testtable is the table name
ck_testtable is the constraint name
testchars is the field name

ALTER TABLE [dbo].[testtable]  WITH CHECK ADD  CONSTRAINT [CK_testtable] CHECK  (([testchars]='a' or [testchars]='b'))
I would use an insert trigger to validate the data, then return a failure code if it is outside of your "acceptable" parameters.
HNA071252Author Commented:
So there's no way you can enter the parameters just like in Access? I'm pretty new to SQL programming, how do I do "insert trigger"?
SQL and access are two completely different beasts. Let me see if I can get something for you...
HNA071252Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.