Constraint Names

This another of those things that bite you, but seems obvious in retrospect.
Make sure to avoid depending on system-generated names for constraints. Foreign keys and default constraints (among others) wil have the system generate a name for them if one is not specified. If the constraint is scripted out and deployed somewhere, it will have a different name.
If you ever need to refer by the object by name, obviously you want the object to have the same name in every deployment.
The system view sys.default_constraints has a [Is_System_Named] column that will identify any default constraints with a system-generated name.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: