|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, May 01, 2013 2:42 PM
Points: 25,
Visits: 126
|
|
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.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: 2 days ago @ 10:59 AM
Points: 2,525,
Visits: 4,324
|
|
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.
_____________________________________________ "The only true wisdom is in knowing you know nothing" "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!" (So many miracle inventions provided by MS to us...)
How to post your question to get the best and quick help
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, March 11, 2013 7:33 AM
Points: 107,
Visits: 120
|
|
Create a trigger that seeks out any child records and deletes them if found.
Eamon
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, May 01, 2013 2:42 PM
Points: 25,
Visits: 126
|
|
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...
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Friday, May 03, 2013 5:35 AM
Points: 803,
Visits: 2,122
|
|
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
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Tuesday, March 26, 2013 8:41 AM
Points: 2,562,
Visits: 3,451
|
|
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---------- While 1 = 1 (Learning SQL....) Click to get fast response of your post
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Tuesday, March 26, 2013 8:41 AM
Points: 2,562,
Visits: 3,451
|
|
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---------- While 1 = 1 (Learning SQL....) Click to get fast response of your post
|
|
|
|