Wednesday, March 28, 2012

Relationships getting deleted (MS SQL)

Dear All,

I got a wierd problem which I haven't been able to explain.

I am working on MS SQL 2000. I don't know for what reason, the
relationship between Parent/Child table is getting deleted. When I
open up the ER diagram in MSSQL Enterprise Manager, I see the
relationship line come up for just a split of a second, and disappears
afterwards. This is the second time I am seeing this thing.

I realized it when I accidently deleted the rows in the Parent Table.
They should not have been deleted as I had associated records in the
Child Table (because of Key Constraints).

Has anyone ever come across this situation? Do you have any
suggestions?

Regards,
TinTin"TinTin" <lalalulu24@.yahoo.com> wrote in message
news:2d5425d1.0410071018.663f4082@.posting.google.c om...
> Dear All,
> I got a wierd problem which I haven't been able to explain.
> I am working on MS SQL 2000. I don't know for what reason, the
> relationship between Parent/Child table is getting deleted. When I
> open up the ER diagram in MSSQL Enterprise Manager, I see the
> relationship line come up for just a split of a second, and disappears
> afterwards. This is the second time I am seeing this thing.
> I realized it when I accidently deleted the rows in the Parent Table.
> They should not have been deleted as I had associated records in the
> Child Table (because of Key Constraints).
> Has anyone ever come across this situation? Do you have any
> suggestions?
> Regards,
> TinTin

The best suggestion is probably don't use EM for this task - it has a
history of glitches and small bugs, and some tasks are simply not possible
at all. The most reliable way to manage your database objects is with TSQL
in Query Analyzer, as you have complete control over what's happening, and
you can easily save scripts for common tasks.

In this case, you can look at sp_help, sp_pkeys and sp_fkeys to get
information about the table and its current primary and foreign keys, and
ALTER TABLE to add or remove constraints.

Simon

No comments:

Post a Comment