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 |
|
rme8494
Yak Posting Veteran
98 Posts |
Posted - 2004-09-27 : 16:52:41
|
| Is it possible to run query, but not have that query record in the transaction log? I have to delete several thousand records and I do not want them to fill up my log.RyanRyan EverhartSBC |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-09-27 : 16:57:27
|
Or here is a better one that I wrote recently:SET NOCOUNT ONDECLARE @RowCnt INTSELECT TOP 100000 ID AS TrailerIDINTO #TempFROM TrailerWHERE DP_LOAD_ID NOT IN (SELECT ID FROM DP_LOAD)SET @RowCnt = @@ROWCOUNTSET ROWCOUNT 5000WHILE @RowCnt > 0BEGIN DELETE t1 FROM Trailer t1 INNER JOIN #Temp t2 ON t1.ID = t2.TrailerID SET @RowCnt = @@ROWCOUNT WAITFOR DELAY '00:00:30'ENDSET ROWCOUNT 0DROP TABLE #Temp I scheduled the above to run every night until the rows were deleted. 100000 per night in 5000 batches.Tara |
 |
|
|
rme8494
Yak Posting Veteran
98 Posts |
Posted - 2004-09-27 : 16:58:53
|
| Thanks Tara, as always you are on the ball!RyanRyan EverhartSBC |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-09-27 : 17:00:12
|
| How many do you want to keep?SELECT * INTO myNew Table FROM myTable WHERE what I want to keepDROP TABLE myTableRename NewTable to OldTableMinimally logged there, and quick...But if like Tara said you've got HUGE amounts of data...(thousand doesn't qualify by the way)My best guess is that you really need to set up a tranny dump.Do you have any maintenance setup at all?Brett8-) |
 |
|
|
clarkbaker1964
Constraint Violating Yak Guru
428 Posts |
Posted - 2004-09-27 : 17:37:25
|
| That's good Brett Why not Truncate Source and Append from TempWe are assuming their are no foreign key constraints which would also have to be dropped and recreated... I would'nt do this unless I was in single user mode.Surf On Dude! |
 |
|
|
|
|
|