Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...sql script to truncate databasesql script to truncate database
Previous
 
Next
New Post
6/15/2009 4:42 PM
 

Hi,

In the past I used the following script to truncate my database.
I' am using now sql 2008.
Now this script gives the error message below.
Is there anybody out there with some advice?

With regards, Ton Hermes

BACKUP LOG c1664_dnn WITH TRUNCATE_ONLY
TRUNCATE TABLE {databaseOwner}{objectQualifier}EventLog
TRUNCATE TABLE {databaseOwner}{objectQualifier}SiteLog
TRUNCATE TABLE {databaseOwner}{objectQualifier}schedulehistory
DBCC SHRINKDATABASE (c1664_dnn);

 

System.Data.SqlClient.SqlException: 'TRUNCATE_ONLY' is not a recognized BACKUP option. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL) at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions) BACKUP LOG c1664_dnn WITH TRUNCATE_ONLY TRUNCATE TABLE dbo.EventLog TRUNCATE TABLE dbo.SiteLog TRUNCATE TABLE dbo.schedulehistory DBCC SHRINKDATABASE (c1664_dnn);


Art is hard work, inspiration is the cream on top of it. See my watercolors at www.watermansite.com and my enamel art at www.watermanshop.com
 
New Post
6/15/2009 6:22 PM
 

In SQL 2005 Truncate_Only was depreciated. It is no longer available in 2008. You can switch recovery modes to acheive the same result.

ALTER DATABASE <%YOURDB> SET RECOVERY SIMPLE
ALTER DATABASE <%YOURDB> SET RECOVERY FULL

 

HTH



 
New Post
6/16/2009 2:15 AM
 

Hi,

So it must be like this?

With Regards, Ton

ALTER DATABASE c1664_dnn SET RECOVERY SIMPLE
TRUNCATE TABLE {databaseOwner}{objectQualifier}EventLog
TRUNCATE TABLE {databaseOwner}{objectQualifier}SiteLog
TRUNCATE TABLE {databaseOwner}{objectQualifier}schedulehistory
DBCC SHRINKDATABASE (c1664_dnn);


Art is hard work, inspiration is the cream on top of it. See my watercolors at www.watermansite.com and my enamel art at www.watermanshop.com
 
New Post
6/21/2009 3:57 PM
 

Sorry Ton, I didn't get notification that you reponded to this thread. Did you get this resolved?

There is no need to perform the ShrinkDatabase command. Unless of course your data file is too large. The items I listed will (in short) drop your DB log file and then recreate a new one.

Truncating the tables you have listed can be done to free up space in the data file, but I generally don't find it nesessary to remove (shrink) the free space in a data file. And shrinking the data file comes with a performance hit, so if your not concerned about disk space, leave the data file alone. Not to mention that frequentely shrinking and growing of database files will fragment your file system, which will further hurt performance.

HTH



 
New Post
6/22/2009 5:37 AM
 

Hi,

No I did not got this resolved.

I tell you why I do this truncation, shrinking.
In the past, when I did nothing< the database was growing and growing in size.
Then when, I wanted to empty the site log, I got an error mentioned that the log file was to big to complete the job.
So I had to find another way to empty the log file.
On the forum I discovered above mentioned script to empty the log file.
This script worked fine.
The database was shrinking from 50 to 25 Mb.

Then I saw on a  site a free DNN module to do this job.
I installed this module.
I though everything was ok now.
However, after a couple of weeks I checked the database and event log again and it was big in size.
I tried to manually empty the log file and got again the error that the log file was to big to complete the job.

I used the old script to do the job again.
However, I upgraded the SQL from 2000 to 2008.
Now I got again an error that this script was not valid anymore.

What shall I do now?
using this?
ALTER DATABASE <%YOURDB> SET RECOVERY FULL

or this?
ALTER DATABASE c1664_dnn SET RECOVERY SIMPLE
TRUNCATE TABLE {databaseOwner}{objectQualifier}EventLog
TRUNCATE TABLE {databaseOwner}{objectQualifier}SiteLog
TRUNCATE TABLE {databaseOwner}{objectQualifier}schedulehistory

or this?
ALTER DATABASE <%YOURDB> SET RECOVERY SIMPLE
ALTER DATABASE <%YOURDB> SET RECOVERY FULL

Thanks for responding.

With regards, Ton Hermes


Art is hard work, inspiration is the cream on top of it. See my watercolors at www.watermansite.com and my enamel art at www.watermanshop.com
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...sql script to truncate databasesql script to truncate database


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out