Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing ON DELETE of FK constraint
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01514140
Message ID:
01514144
Vues:
40
>Hi,
>
>I want to create the following foreign key constraint:
>
>
>alter table [dbo].[table1] add constraint [FK_table1_building]
>foreign key ([building],[site_no])
>references [dbo].[buildings] ([building],[site_no])
>on delete set null
>on update cascade
>
>
>But the above constraint requires that the table Table1 has column SITE_NO (int) as NULL. But I want that the SITE_NO to be NOT NULL. That is, when the entry is deleted from Buildings table I want the column Building in Table1 to be set to NULL but leave the SITE_NO column left without change. Is this possible? Can I modify the ON DELETE part of the above syntax to make it work as I want it? TIA.

That's job for trigger :-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform