Validation in SQL Server 2005 Express?

  • In Access we had the possibility to implement a validation rule when creating a field, so that it would only accept certain values. For the life of me I can't find a similar option in Microsoft SQL Server Management Studio Express. I've been searching google for the past half hour and the only thing I've found was a reference to the fact that Microsoft did away with the validation option and instead, allows one to create their own data type which allows them to do the same thing. But again, I can't find any info on how to do this. Any help would be much appreciated.

  • http://www.devx.com/dotnet/Article/22644

    This explains how to create a UDT in VB.Net or C# and register it in SQL 2005 so that it is a datatype like char or varchar, except it follows your rules.

    http://download.microsoft.com/download/f/1/0/f10c4f60-630e-4153-bd53-c3010e4c513b/ReadmeSQLEXP2005.htm

    Look at 5.3 and 5.5 for more info on this.

  • Try a check constraint at the column level. I believe Express supports it.

    MG

    "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
    Tony Hoare

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.

  • Welcome to SQL Server!

    You want to set up column constraints.

    Here's a decent article describing contraints with a few examples.

    http://www.mssqlcity.com/Articles/General/using_constraints.htm

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply