Solved

Transaction log full-- insert into table1 select * from table2

Posted on 2002-05-13
7
4,043 Views
Last Modified: 2007-11-27
I am getting transacation log full while inserting data into a table.
I used following command.
insert into table1
select * from table2.
Table2 is having 1700000 rows.
I want all the rows to be inserted into table1 from table2.
I don't want to log any thing. Is there any way/technique to escalate transaction log.

Please help ASAP.

thanks,

hmk.
0
Comment
Question by:hmk
7 Comments
 
LVL 5

Expert Comment

by:amitpagarwal
Comment Utility
if table1 is empty, you may try a select * into operation as that is a non logged transaction.

drop table1
select * into table1 from table2

or if you cant do that ..

try running your query in a while loop with set rowcount.

thanks.
0
 
LVL 3

Expert Comment

by:ahoor
Comment Utility
Amitpagarwal, if you use 'select into' to copy the 1.7 million rows this will work, however if you decide you need an index on the table this may cost a lot of time.
So I wouldn't suggest that, unless you don't need an index.

I would go for the batchwise insert, remind that the setting 'trunc log on chkpt' must be true for the specific database.
0
 

Author Comment

by:hmk
Comment Utility
table1 is permanent table. we can't drop table every time we insert data( I don't have any admin previleges on the table). And also table1 has indexes on it.

Amith : I know loop technique works. Could u send me while loop code.

ahoor: what is this 'trunc log on chkpt'? what it do?


thanks,

hmk
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 3

Expert Comment

by:ahoor
Comment Utility
"ahoor: what is this 'trunc log on chkpt'? what it do?"

It is a databaseoption which clears the log everytime a commit occurs. You will need this if you use the loop technique.

use master
go
sp_dboption db_name, 'trunc log on chkpt', true
go
use db_name
go
checkpoint
go

where db_name is the name of the database the transaction ocurs.
0
 
LVL 3

Accepted Solution

by:
pg_vinod earned 50 total points
Comment Utility
Following steps can be performed when you are getting 'transacation log full ' message.

First try to truncate the log with truncate_only option . If it fails then use NO_LOG option to clear the log.

Then:-
If you have more disk space then you can extend your log device space. More space will give less chance for log full.
(OR)
You can set database option to 'trunc log on chkpt' if the tran backup to disk /Tape is not important for you. 'trunc log on chkpt' database option will truncate all the tran log by having checkpoint on database.
(OR)
if you are not allowed to do above steps the Breake your insert transaction to batches.

good luck,
p.G.Vinod
0
 
LVL 3

Expert Comment

by:ahoor
Comment Utility
Sorry but a 'trunc log on chkpt' will not be enough if you try to do the transaction in one time, because there will be no checkpoints.

Also the 'accepted answer' is nothing more than repeating Amit and my solutions, but not in a workable way. Alright, if you increase the logsize, it may work. However keep in mind that the log cannot easily be decreased.

So this 'solution'

"You can set database option to 'trunc log on chkpt' if the tran backup to disk /Tape is not important
for you. 'trunc log on chkpt' database option will truncate all the tran log by having checkpoint on
database.
(OR)
if you are not allowed to do above steps the Breake your insert transaction to batches
"
should be AND instead of OR. As Amit and I already stated.
0
 
LVL 3

Expert Comment

by:ahoor
Comment Utility
What I mean is maybe you can explain why it is this response you decided to be the best...
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now