Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing ON DELETE of FK constraint
Message
De
11/06/2011 15:46:42
 
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:
01514148
Vues:
42
>>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 :-)

Thank you, Borislav.
"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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform