Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Set NULL

Author  Topic 

anizami
Starting Member

4 Posts

Posted - 2005-04-08 : 15:17:26
hi im trying to enforce refrential constraints in sql 2000
how do we do ON DELETE SET NULL in T-SQL for server 2000. Ive done it in oracle but somehow sql server has some limitation.

thanks!

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-04-08 : 15:23:17
what do you want to set to null when you delete something?


Go with the flow & have fun! Else fight the flow
Go to Top of Page

anizami
Starting Member

4 Posts

Posted - 2005-04-08 : 15:41:47
i havea foreign key which i want to set to null incase it has been deleted in the parent table.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-04-08 : 16:00:42
use after delete trigger for this. read about them in BOL = Books Online = SQL server help

Go with the flow & have fun! Else fight the flow
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-04-08 : 17:46:59
In sql 2005, I hear You can do this....(blah blah)

In sql 2000 You have to work around the problem in some way.
I just wonder why would You ever! want to delete a parent record that has child records,
can't think of a business case

The problem with the after trigger approach, is that the trigger runs after RI has been checked,
so it will not work so well.

rockmoose
Go to Top of Page
   

- Advertisement -