Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Find name of Default Constraint?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
00478230
Message ID:
00478534
Vues:
26
>>Hi All,
>>
>>Is there a way to find out the name of the Default Constraint that is created when you use the DEFAULT Clause of the CREATE TABLE statement?
>>
>>I haven't been able to find them in the INFORMATION_SCHEMA views. Currently, I ALTER the column and then cut and paste the name. I'd like to automate this in a stored procedure.
>
>
>Ok. To find the DEFAULT Constraint on mc_mdsvc.svc_ln I can do this:
>
>SELECT O.Name
>	FROM sysobjects O, syscolumns C
>	WHERE O.Parent_Obj = OBJECT_ID('mc_mdsvc')
>	AND C.Id = OBJECT_ID('mc_mdsvc')
>	AND O.Id = C.Cdefault
>	AND C.Name = 'svc_ln'
>
>
>However, I've been told not to query the system tables directly. Is there an acceptable way to do this?
>TIA,

sp_helpcontraint 'mytable' returns 2 result sets. The first contains the name of the item being checked. The second returns all constraints defined for the specified table. You could query this result for the occurrence of DEFAULT in the contraint_type field as well as he filed it is bound to. The name is stored in the contraint_name field.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform