Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing ON DELETE of FK constraint
Message
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Changing ON DELETE of FK constraint
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01514140
Message ID:
01514140
Vues:
105
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.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform