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.
Author |
Topic |
rahulm_32003
Starting Member
7 Posts |
Posted - 2012-09-05 : 21:42:09
|
I have bunch of tables contains huge number records. All the tables are referring a primary key of table T1.Now.I have to write a stored procedure to delete the records in batches.I am new to SQL server programming .Please help me in writing this stored procedureScenario:T1---primary key x1T2- referential x1T3-referential x1T4-referential x1 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-05 : 21:43:55
|
why do you need to do it in batches? does it have something to do with log space etc?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
rahulm_32003
Starting Member
7 Posts |
Posted - 2012-09-05 : 21:52:03
|
when there is huge number of records its taking too much time.If we do it batch commits even if forcefully kill the process we dont lose everything except the last batch |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-05 : 22:07:31
|
ok..makes sense then. do you've primary key in each of tables? are they related to each other by means of fk?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
rahulm_32003
Starting Member
7 Posts |
Posted - 2012-09-06 : 00:18:04
|
Yes.Some tables have primary keys but most of them are reatled to each other by means of table T1 primary key |
 |
|
|
|
|