October 18, 2012 at 8:55 am
i have datawarehouse database where there is only primary key and no foreign keys.
I have a condition from one table and based on that condition i have to delete the records from other tables.
I am trying to use joins and delete the records based on that condition. Is this right way or else anyother way to delete.
October 18, 2012 at 9:35 am
raghuveer126 (10/18/2012)
i have datawarehouse database where there is only primary key and no foreign keys.I have a condition from one table and based on that condition i have to delete the records from other tables.
I am trying to use joins and delete the records based on that condition. Is this right way or else anyother way to delete.
1. It might be the right way.
2. There is a possibility that there are other ways exist which you can use to delete.
That about the best answer I can think of, based on details you have provided.
October 19, 2012 at 5:28 am
Create a trigger that seeks out any child records and deletes them if found.
Eamon:-)
October 22, 2012 at 5:14 pm
Hi Thank you for the reply..
I did inner join put a where clause and deleted one table there were x rows affected but when i try to put one more table from the inner joins i used in the delete statement it is not deleting the related records in that table, it says 0 rows affected.
If it has no foreign keys than how do i know which table to delete first...
October 23, 2012 at 12:45 am
I would be very nervous about deleting records from a DW as the nature of them can mean that while its ok to delete from dimensions based on one set of requirements, you could actually be deleting valid records that are required by other Facts that dont meet those requirements.
Can you explain why you need to delete these records and what type of DW it is? (eg Star Schema, Snowflake, Incremental/Snapshot load)
_________________________________________________________________________
SSC Guide to Posting and Best Practices
October 23, 2012 at 4:31 am
EamonSQL (10/19/2012)
Create a trigger that seeks out any child records and deletes them if found.Eamon:-)
i didnt see any comment from OP that he wants to delete data with every DML operation .its by choice or i would say manual call
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
October 23, 2012 at 4:35 am
raghuveer126 (10/22/2012)
I did inner join put a where clause and deleted one table there were x rows affected but when i try to put one more table from the inner joins i used in the delete statement it is not deleting the related records in that table, it says 0 rows affected.If it has no foreign keys than how do i know which table to delete first...
first you should verify the data by select it before deleting it. another thing one query will delete the data from one table at a time (i havent seen anything link Delete table1, table2 from .............) then another query for second deletion
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply