| Author |
Topic |
|
sachinsamuel
Constraint Violating Yak Guru
383 Posts |
Posted - 2007-01-23 : 08:09:17
|
| Hi experts,What is the difference between, Creating rules and creating checks on a field?They both look the same.RegardssachinDon't sit back because of failure. It will come back to check if you still available. -- Binu |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-01-23 : 08:55:46
|
same thing basicaly but CREATE RULE will be removed in future version of SQL.so check constraint is the way to go.Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
|
sachinsamuel
Constraint Violating Yak Guru
383 Posts |
Posted - 2007-01-23 : 09:03:59
|
| Thanks spirit,But I think this could be a difference. A rule is something outside a table which can be used other tables in the database. But a check is private to only the table, which can be accessed only by the table it is applied on. Thats the reason its called constraint on the table. Don't if that make sence.RegardsSachinDon't sit back because of failure. It will come back to check if you still available. -- Binu |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-01-23 : 09:07:50
|
yes you're right.but since it's deprecated anyway, why use it?Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-01-23 : 09:10:57
|
| Rules are provided only for the backward compatibility and they are not ANSI-compliant. Besides that, you can specify only one rule per column whereas you can have multiple CHECK constraints on a column.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
DavidWP
Starting Member
2 Posts |
Posted - 2009-02-09 : 13:56:21
|
It's now 2009 and I am using rules in SQL Server 2008. When exactly were they supposed to disappear? My preferences for them over check constraints is in their ability to manage change in large systems. Has the plan to abandon them been abandonned? |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2009-02-09 : 14:20:18
|
| Rules have been documented in SQL Server Books Online as a backward compatibility feature since at least SQL Server 7.0 (1997).From SQL Server 7.0 Books Online:"CREATE RULE (T-SQL)Creates an object called a rule. When bound to a column or a user-defined data type, a rule specifies the acceptable values that can be inserted into that column. Rules, a backward compatibility feature, perform some of the same functions as check constraints. CHECK constraints, created using the CHECK keyword of ALTER or CREATE TABLE, are the preferred, standard way to restrict the values in a column (multiple constraints can be defined on a column or multiple columns)."From SQL Server 2008 Books Online:"This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. We recommend that you use check constraints instead."CODO ERGO SUM |
 |
|
|
DavidWP
Starting Member
2 Posts |
Posted - 2009-02-10 : 10:29:57
|
| I have been reading the same books but the action to make this happen has not been taken, not even in the new release. I was curious if there was someone on this thread from MS in SQL dev who could discuss in more detail. |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2009-02-10 : 11:19:12
|
| It's like a walk in the fog near the sea-side and you aren't sure exactly where you are: there's a cliff somewhere. You've been told to be careful and choose a different route.take a step..... nope no cliff - no need to change route. OK take another step..... nope still no cliff. take another step.....Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2009-02-10 : 21:43:27
|
quote: Originally posted by DavidWP I have been reading the same books but the action to make this happen has not been taken, not even in the new release.
That's very true, but they also said the same thing about the *= outer join syntax, deprecated since 6.0 but not actually removed until 2008. Some people have been caught off guard by that, and it's AT LEAST 10 years after.Charlie's advice/analogy is extremely apt. How bad would you feel if you couldn't upgrade to the next version just because of this one feature that's (granted) very handy but someday just won't be there? It's no fun stuck on a prior version with creaky code that could be replaced with one-line wonders in the next version, just because of a *= somewhere that just doesn't quite work as a left join.Besides, it's fairly trivial to query for all the columns that are bound to a rule and generate check constraints for them.My hope is that they add CREATE DOMAIN support to Kilimanjaro, and if they do, you won't care about rules anymore. |
 |
|
|
|