Solved

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

Posted on 2002-05-13
7
4,119 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 5

Expert Comment

by:amitpagarwal
ID: 7010197
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
ID: 7010536
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
ID: 7011695
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
Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

 
LVL 3

Expert Comment

by:ahoor
ID: 7013543
"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
ID: 7021007
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
ID: 7024336
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
ID: 7024341
What I mean is maybe you can explain why it is this response you decided to be the best...
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Successful collaboration among team members is essential for the growth of your business. When employees work together on projects, share ideas and communicate effectively they get better results.
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

632 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