Jeff's SQL Server Blog

Random Thoughts & Cartesian Products with Microsoft SQL Server
posts - 157, comments - 2686, trackbacks - 64

My Links

Advertisement

News

Welcome to my weblog. My name is Jeff Smith, I am software developer in Boston, MA and I was recently named a 2009 SQL Server MVP. Check in frequently for tips, tricks, commentary and ideas on SQL Server and .NET programming.


Subscribe





Archives

Post Categories

Programming

Sports

SQL

SQL Server 2005 Foreign Key Constraints: SET NULL and SET DEFAULT

Most people know about cascading updates and deletes, but did you know there are two other foreign key constraint options you can use to maintain referential integrity?

Read all about them in my latest article over at SQLTeam.com.

These features, introduced with SQL Server 2005, haven't got a lot of publicity, but they can be very useful.  I just used the SET NULL option recently for the first time (inspiring me to put together an article on it) and it works great.

Print | posted on Wednesday, August 13, 2008 9:56 AM | Filed Under [ Database Design Links Joins/Relations ]

Feedback

Gravatar

# re: SQL Server 2005 Foreign Key Constraints: SET NULL and SET DEFAULT

fine thanks
9/26/2008 11:26 AM | nilesh
Gravatar

# re: SQL Server 2005 Foreign Key Constraints: SET NULL and SET DEFAULT


I'm loading a dataset from a cached viewstate version of the dataset
created

"Failed to enable constraints. One or more rows contain values violating
non-null, unique, or foreign-key constraints"
I suspect this is due to a field in one of the tables which can be null,
but
if it is not null it is a foreign key to another dataset table. At
present
the field in this table is null (in the database).

What attributes of the dataset table field, or the dataset constraint
should
I set to indicate null values don't violate the constraint?

by
seemu
12/13/2008 12:58 AM | seenu
Gravatar

# re: SQL Server 2005 Foreign Key Constraints: SET NULL and SET DEFAULT

Really. I did not know about this until now...
Anyway I don't think we should use cascades in regard of integrity.
thanks, Vadym
1/23/2009 2:57 PM | DBA
Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET