Compacting A Db Via T-SQL
Mar 23, 2004
Hello dbForumers,
I was wondering if there is a way (MUST be) to instruct SQL server to compact a chosen database's files. I have a batch that runs every night who generate a huge amount to log lines that I get rid of with a backup log xxx with truncate_only, but still the logfile is several GB big afterwards with a lotsa empty space... I wanna get a clean small file everyday =)
Thank you!
View 2 Replies
Nov 10, 2006
Hi
for mS SQL 2000-2500
LDF and MDF files can be very very big, if I import the datas into a new database they can become 10 time smaller
is there a way to compact (reduce the MB) of a database ?
thank you
View 4 Replies
View Related
Nov 14, 2006
how can you compact .log file ?
they can be > 20 gigas ! ....
can you delete it ?
View 3 Replies
View Related
May 12, 2008
I'm trying to compact a SQL CE database programmatically. I've copied the code from MSDN, and it's fine as far as it goes, but there's a problem tying to compact a database in a ClickOnce application because you don't know the path to the database. You have to use the "|DataDirectory|" in your connection string to signify the path to the database. But when I try the file operations to replace the old database with the compacted version, I get an error message that the path "|DataDirectory|" is not valid. Here's the code:
SqlCeEngine engine = new SqlCeEngine("Data Source = " + src + "; Password =" + txtPassword.Text);
try
{
engine.Compact("Data Source = " + dest + "; Password =" + txtPassword.Text);
ShowMsg("Compacting...", MsgType.NoError);
}
catch (Exception ex)
{
MessageBox.Show("There was an error completing the operation: " + ex.Message);
}
engine.Dispose();
File.Delete(src);
File.Move(dest, src);
(dest is = src + ".tmp", i.e., a path to a tmp file to hold the database while compacting).
How do I locate the files to copy if I can't use "|DataDirectory|"?
View 3 Replies
View Related