Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changing ON DELETE of FK constraint
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01514140
Message ID:
01514148
Views:
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 :-)

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
Previous
Reply
Map
View

Click here to load this message in the networking platform