Solved

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

Posted on 2002-05-13
7
4,065 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Alternative to ALTER in Sybase 1 396
SQL Left join on same table 4 301
SyBase Query Syntax Date Time conversion 4 27
sybase output only middle rows 4 15
Note: This is the second blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   Every month t…
Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 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

12 Experts available now in Live!

Get 1:1 Help Now