Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2002-05-13
7
Medium Priority
?
4,146 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
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 200 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Files go missing when using DFS (Distributed File System) Replication and how to recover them and fix it.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

715 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