all groups > sql server programming > june 2003 >
You're in the

sql server programming

group:

avoid writing to log file on insert


avoid writing to log file on insert Jed Ozone
6/30/2003 8:55:53 PM
sql server programming:
Is there any way to NOT write to the Log File when doing an INSERT on a
database setup as Simple? I am hoping there's some T-SQL syntax that can
prevent the INSERT from being logged.

I have a table I write to but I don't care if it's saved. All the inserts
on the table cause the Log to grow sometimes considerably on some days.

Related question: I'm assuming if using transactions (begin, committ, etc.)
that you need a Log File. Or is this not true? In the above case, I need
to be able to do transactions on some tables, but I don't care about the Log
File as far as doing backups, etc.

Re: avoid writing to log file on insert Andrew J. Kelly
7/1/2003 10:10:34 PM
Jed,

First off you might want to check your system date as it seems to be off a
few days. But to answer your question there is no way to turn off logging.
Every thing is logged to some extent or another. Most are fully logged
operations but you can achieve what is called a Minimally logged load under
certain circumstances, but a straight insert is not one of them. Things
like BCP, Bulk Insert and Select Into can be minimally logged if the
conditions met under the "minimally logged load" section of BCP in
BooksOnLine is met. If your doing lots of inserts then you should do them
in batches and backup the log in between. If your in simple mode you can
just truncate it or if you do it in batches it should truncate on it's own
eventually. Don't wrap all the inserts in one big transaction or you can't
do either.

--

Andrew J. Kelly
SQL Server MVP


[quoted text, click to view]

Re: avoid writing to log file on insert Jed Ozone
7/1/2003 10:45:29 PM
Andrew, thanks for the info (and noticing my date was off!). Hopefully
doing something like having Truncate Log on Checkpoint set on the database
and then issuing the checkpoint command periodically will work. Doing
something like every 1000 inserts I could then issue a Checkpoint command
should work I think (unless I'm completely misunderstanding the usage of
Truncate on Checkpoint and the Checkpoint command). Trying to keep the
program functioning as is. I just want to reduce the log size if possible.

[quoted text, click to view]

AddThis Social Bookmark Button