Saturday, February 25, 2012

Rules and defaults

Hi,

Can any one provide me information on creating rules and defaults in SQL Server2005, when i tried right clicking rules or defaults in management studio instead of new option i'am getting only refresh option.

This feature was working smoothly in sql2000.....I'am trying this on Microsoft SQL Server2005 Standard Edition.

thanks in advance

Mat

Rules and defaults are deprecated in 2005. You should now use constraints, which you define in the table designer. Rules and defaults are still supported, but you have to create them manually by writing the code yourself. You cannot create them in Management Studio because you should not be using them any more.

This comes from the 2000 documentation
"Rules are a backward-compatibility feature that perform some of the same functions as CHECK constraints. CHECK constraints are the preferred, standard way to restrict the values in a column."
"Defaults, a backward compatibility feature, perform some of the same functions as default definitions created using the DEFAULT keyword of ALTER or CREATE TABLE statements. Default definitions are the preferred, standard way to restrict column data because the definition is stored with the table and automatically dropped when the table is dropped."

And this from the 2005 documentation
"CREATE RULE will be removed in a future version of Microsoft SQL Server. Avoid using CREATE RULE in new development work, and plan to modify applications that currently use it. We recommend that you use check constraints instead."
"CREATE DEFAULT will be removed in a future version of Microsoft SQL Server. Avoid using CREATE DEFAULT in new development work, and plan to modify applications that currently use it. Instead, use default definitions created using the DEFAULT keyword of ALTER TABLE or CREATE TABLE."

No comments:

Post a Comment