Solved

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

Posted on 2002-05-13
7
4,103 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sybase ASE BCP In With Table with No Identity Column 1 1,217
SyBase SQL Syntax 4 677
Call sybase stored procedure from php 8 94
Need help with SYBASE syntax 5 109
Invest in your employees with these five simple steps to improve employee engagement and retention.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

710 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