Truncation Of Transaction Logs Using SSIS

Feb 8, 2008


HI,

What I have set out to do is to try and truncate the transaction logs on my server instances after a nightly backup. I went ahead and used the shrink database option in the maintenance plan wizard. Unfortunately I have found this will only truncate the logs for databases using the simple database recovery model, and I wish to truncate the whole lot to save space...

I went ahead and put together an SSIS package that does the following:

1. First thing I do is build a fresh copy of a database listing in a temp table using the following SQL statement

USE Master;
Go
SELECT name, DATABASEPROPERTYEX(name, 'Recovery') AS RecoveryModel, DATABASEPROPERTYEX(name, 'Status') AS DBStatus INTO TempTables.dbo.Recovery FROM sysdatabases ORDER BY name
GO

2. Next I read this dataset back into memory using a SQL statement as follows:

USE TempTables
GO
Select name from dbo.recovery Where name <> 'master' and name <> 'model' and name <> 'msdb' and name <> 'tempdb'

I map the results to a results set called User::TableName (which is of an object data type)

3. Next the package goes to a ForEach Loop container and I use the Foreach ADO Enumerator Enumerator to read the data I just selected into the look. I select the User::TableName variable and use the enumeration mode 'Rows in first table'. I have used a variable mapping of Variable: User::TableName with an Index 0.

4. I then use the following SQL statement (which sits in the For Each Loop) to try and alter the recovery model:

ALTER DATABASE @TableName
SET RECOVERY SIMPLE;
GO
This is where the package falls over with the following error message

SSIS package "mnt_TransLog.dtsx" starting.
Error: 0x0 at Simple Mode: Incorrect syntax near '@TableName'.
Error: 0xC002F210 at Simple Mode, Execute SQL Task: Executing the query "ALTER DATABASE @TableName
SET RECOVERY SIMPLE;
" failed with the following error: "'RECOVERY' is not a recognized SET option.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Task failed: Simple Mode
Warning: 0x80019002 at For Each Table Set to Simple: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (2) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
Warning: 0x80019002 at mnt_TransLog: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (2) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "mnt_TransLog.dtsx" finished: Failure.

I think the problem here is either I am not passing the variable across correctly (i.e. not declaring it or something..!) or I am passing the wrong type of variable across.

Once the recovery model is changed I can truncate the transaction logs successfully but I can€™t seem to until this is done! Any help in finding a solution to this problem or a better way of approaching this problem would be appreciated!

Thanks

Marek Kluczynski
Management Information Officer
Investors in People UK
7-10 Chandos Street
London
W1G 9DQ
Tel: 020 7467 1956

View 3 Replies


ADVERTISEMENT

Transaction Log Truncation

Sep 6, 2007



I have always assumed that when you backup a SQL Server database the transaction log is automatically truncated so that there is no need to explictly truncate it. It makes sense to me, you would not normally need logs from before the most recent backup. BOL, with all its talk about check points etc, seems to hint at this but I can't find an explicit statement to this effect.

Anyone?

Dick Campbell

View 5 Replies View Related

Log Truncation Vs Transaction Backup

Jun 13, 2001

If we choose "truncate log on checkpoint", then we cannot backup the transaction. May someone tell me what's the difference between them and the advantage over the the other.

Thanks.
yatie

View 3 Replies View Related

SSIS Logs Vs Custom Logs Components

Feb 12, 2007

Hi,

In my case I have to log the errors raised by any task in a package to either windows event log, text file or SQL server. Also I need to send an email notifications to a group of people telling them about the error.

Now can I use SSIS package logging for logging the errors into the required destinations. I mean right clicking on the package and selecting Logging, then adding the required log providers and enabling the events for logging into those. I think I have to upfront select the log providers to log the error, I will not have the liberty to log the error to the destination, the name of which is passed as a variable to the package. This is okay with me though.

Now what will a custom log provider help me to do in this case. Also can I somehow configure my package to call the send mail task everytime an error is raised.

Also, one more option can be developing a package that only does the error handling. It will take in the paramters or the error codes and descriptions, the destination to write to and a flag to send mail or not for that particular type of error.

What do you think? Kindly advise.

Thanks in advance for your help and time.

Regards,

$wapnil

View 3 Replies View Related

Re Truncation In SSIS

Jan 14, 2008



Hello Guys I am using XML files and dumping data to sql server 2005 , i have field called as rate which is having money as datatype and i am getting following error


LoadDataXML to XML Source -- LoadDataXML [907]: The value was too large to fit in the output column "RATE" (95245).

please help me out with the solution of this ...the data which is coming from xml file is unsigned itneger single bit and my database is having money .so should i use a conversion task in between if any body can give idea about this that would be great , if you want more information tell me ...
thanks
krish

View 5 Replies View Related

Transaction Logs

Apr 24, 2002

What is the best way to clear the transaction logs. My backup job each night is ending because it says it is running out of disk space and I need to clear up the transaction logs. Any help is appreciated. I see many different options (trucate option, auto shrink, etc.), just need some assistance tosome more specific best approaches. Thanks

View 3 Replies View Related

Transaction Logs

Aug 13, 2001

Im having issues truncating my transaction logs. I have logs in excess of 40 gigs. All the info in the BOL is very vague. Any assistance would be apreciated.

Regards

SeTi Ni

View 5 Replies View Related

Transaction Logs

Jun 22, 2000

When we backup the transaction log,will it truncate the log or it will grow from there?Truncate log on check point is desabled.
Thanks!

View 2 Replies View Related

Transaction Logs

Aug 30, 2000

to take the transaction log back up regularly I should have truncate log on check point false. If I do so then how will I truncate the log.
regards,
Renu

View 3 Replies View Related

Transaction Logs

Aug 20, 1998

I am trying to import records via bcp (about 1,500,000 records) and I keep running out of disk space. Is there any way to limit or do away with the transaction log (and still be able to import)?

View 2 Replies View Related

Transaction Logs Help!!!!!!!!!

Dec 14, 1999

how do i decrease the transaction log example 500mb to 100mb, can you help me with the syntax pls!!

View 1 Replies View Related

Transaction Logs

Sep 2, 2004

I need to move transaction logs to a different drive and am looking for a way to do it without detaching the db.

Can I create a second transaction log file for the DB and then delete the original log file?

What is the best way to do this for db's that are being replicated?

Thanks,
Ken Nicholson

View 3 Replies View Related

Transaction Logs

Jun 13, 2002

I need to seperate my SMS data files and transaction logs onto two seperate drives. Can anyone assist me with this?

thanks...

View 1 Replies View Related

Transaction Logs

Aug 2, 2004

HELP!!!!

When I look at the Database maintience plan history entry for backup I have a message that reads: "Backup can not be performed on this database. This sub task is ignored".

Have anyone come across this error before?? As part of the Maintenance plan some transaction log are being backup and some aren't instead they receive the message above.

Thanks

Lystra

View 2 Replies View Related

Transaction Logs

Nov 19, 2004

Has anyone ever had the problem of the IT department not backing up thier transaction logs simply because they didnt find it necessary??

View 3 Replies View Related

Transaction Logs

Jan 8, 2004

i have several sql servers doing maintenance plans and backing up the transaction logs to tape. unfortunately it seems that the server keeps adding the transaction logs to the same tape, without overwriting them. Nowadays a transaction log backup to disk takes 2 minutes but when done to tape it is taking up 1hr54minutes. What can i do so that the tape is automatically initialised without having to do it manually... Thanks

View 1 Replies View Related

Transaction Logs

Apr 9, 2008

i was wondering if smeone could give me a breif over view how far back do these go

View 12 Replies View Related

Transaction Logs And LDF

Jun 11, 2008

HI All,

Is this is a good idea or not?

If i attached my SQL Server to SAN only for DATA and LOG (Ldf) drives
through the FC. then we put *.bak and *.trn on to local disk RAID 1 drive?

Any performance isues?

View 3 Replies View Related

Transaction Logs

Dec 7, 2007

Is there a way to view the transactions from a .TRN transaction log file? If so can I overwrite some of the transactions on the file and then restore from it? I am just curious.

View 2 Replies View Related

Transaction Logs

Mar 11, 2007

Hi, I know just about nothing about SQL Server. I am getting this error:The log file for database 'my_database' is full. Back up the transaction logfor the database to free up some log space.I can't access the transaction logs to back them up. I am told that my ISP'stech support should have it set up to shrink those logs automatically everyso often. Is that true?Why are they needed? Up till Monday, the logs are just of our getting SQLServer set up, so couldn't the logs just be deleted? Most of my site can'trun with this problem.I'd appreciate any enlightenment anyone can give me!Thanks, Jill

View 1 Replies View Related

Transaction Logs

Jul 20, 2005

This seems like it'd be a really stupid question, but for the life of me Ihaven't been able to find an answer that works....I have a database that's approximately 400MB when shrunk... and thetransaction logs are at about 4.8GB when shrunk... I can't seem to get thetransaction log any smaller, no what I try. How can I get the log downbelow 1GB and keep it there? I've only got an 18GB hard drive and I need torun 2 copies of this database.-steve

View 4 Replies View Related

SSIS, Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Feb 22, 2007

I have a design a SSIS Package for ETL Process. In my package i have to read the data from the tables and then insert into the another table of same structure.

for reading the data i have write the Dynamic TSQL based on some condition and based on that it is using 25 different function to populate the data into different 25 column. Tsql returning correct data and is working fine in Enterprise manager. But in my SSIS package it show me time out ERROR.

I have increase and decrease the time to catch the error but it is still there i have tried to set 0 for commandout Properties.

if i'm using the 0 for commandtime out then i'm getting the Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

and

Failed to open a fastload rowset for "[dbo].[P@@#$%$%%%]". Check that the object exists in the database.

Please help me it's very urgent.

View 3 Replies View Related

Reading Transaction Logs?

Jan 8, 2008

Hello,
I am trying to figure out the time a certain store procedure  was executed. I know the SP's name and approximetly the time it was executed. Is this possible to do?
Honestly, i am not sure if SQL server 2005 is smart enough to keep track of commited transaction on the server.
 
Any suggestins?
Thanks

View 2 Replies View Related

SQL 7.0 Transaction Logs Won&#39;t Shrink!!!

Jun 5, 2002

I have seen quite a few people post this type of problem, but I am finding few solutions. Your advice and/or experiences are greatly appreciated.

Here's my scenario:

Environment: Windows NT 4.0 SP 6, SQL 7.0 (set up for Transactional Replication)

Problem: We have several remote dB machines configured for full recovery. On these machines are several dB's that are capturing aprox. 280 data points per second per unit. (Each dB represents one unit, and we have 21 units) No problem here. The problem is the transaction logs, that obviously grow profusely, will not SHRINK after, backups, dbcc commands and TSQL has been issued in failed attempts to shrink the logs. (in other words we've tried everything)

My questions are:

1. Because we are replicating, is it absolutely necessary to configure dB's for FULL recovery? How do I check in 7.0 if the dB is certainly in FULL vs. SIMPLE recovery mode?

2. I work with SQL 2000 and shrinking files is no problem. How can we shrink these log files in SQL 7.0?

It is rather urgent I find a solution as we are running out of hard drive space on our remote machines. Please help :-(

Christine

View 1 Replies View Related

Truncating Transaction Logs.

Jun 7, 2001

I am having trouble Truncating a Transaction Log. I`ve tried everything in Book Online.
I`ve backed up the database, I`ve tried DBCC SHRINKFILE, DBCC SHRINKDATABASE, BACKUP LOG TRUNCATE_ONLY ...etc, but it will not shrink. Any suggestions ? Thanks.

View 1 Replies View Related

How Can I Move Transaction Logs?

May 4, 2000

Currently, my databases and their corresponding transaction logs are all on the same disk array. I finally was able to acquire a seperate disk, specifically to seperate the logs, in case of failure, etc.
Now, I need to figure out how to go about moving the tansaction logs off the current disk array and on to the new disk.
In Enterprise Manager, I brought up "Properties" for the first database, and went to the "Transaction Log" tab. Clicked on the "browse" or "..." button in the location field and got the following message:
"A transaction log file's physical name cannot be changed once the transaction log file has been created". :(

I have been looking through Books On Line, but have been unable to find anything helpful yet.

Can anyone help me figure out how to go about moving a transaction log's location? There has to be some way.
Even if it involves shutting down the server, altering system tables, etc. I need to get these moved.

Your help is appreciated. Thanks.

View 2 Replies View Related

Help !!! None Of My Transaction Logs Are Getting Backed Up

Jan 19, 2001

Hi all,

I have set up a maintenance plan to backup my databases but when I view the maintenance plan history the transaction log backup steps have a success tick but a message saying :

"Backup can not be performed on this database. This sub task is ignored"

I have looked in my backup directory and only see *.BAK files and no *.TRN.
The transaction logs are supposed to back up at 1AM and the databases at 2AM

All my databases being backed up have the truncate log on checkpoint option set. Is this best practise according to my backup schedule ?

Help !!!!

Regards,

Tim

View 4 Replies View Related

Moving Transaction Logs

Jun 15, 2000

Is it possible to move .ldf's to another drive. For example I would like to move a database transaction log file from C:mssql7data to D:mssql7logs.

How can this be done?

TIA!
JJ

View 1 Replies View Related

Restoring From Transaction Logs.

Aug 28, 2000

Hi all,

I am restoring database from Transaction Logs. I followed all the steps
mentioned in the book. Just before the last step there are three options
1. Leave Database Operational. No Additional Logs can be Restored.
2. Leave Database Nonoperational But Able to Restore Additional
Transaction Logs.
3. Leave Database Read_Only And Able To Restore Additional Transaction Logs.

Option 2 and 3 aresupposed to set on the NORECOVERY flag.

I tried both options 2, and 3 , But still got messages that I did not
specify WITH NORECOVERY or WITH STANDBY.

Can anyone please tell me what I am doing wrong?

Thanks in Advance.

Attaullah

View 2 Replies View Related

Emptying Transaction Logs - SQL 6.5

Jul 11, 2000

I am currently having a problem with a transaction log not emptying even when backed up and truncated. I have done a full database backup and then a transaction log backup expecting this to flush the log however the log is not emptied and it is growing larger and larger. Even when I truncate the log it still doesn't free any space up. Can anybody out there spot the fundemental error in my working??? most grateful. Andy (SQL allegedly)

View 1 Replies View Related

Transaction Logs In Sql2k

May 24, 2003

I am new to sql2k
previously i used to work with sql7

how do i clear the transaction logs in sql2k

pavan

View 2 Replies View Related

Shrinking Transaction Logs In 7.0

Aug 20, 1999

I have a transaction log with 22mb of used space and 2,632.50MB of free space. I tried using the following statement to shrink the log and it did not do anything:
USE DB
GO
DBCC SHRINKFILE (DB_log, 50)
GO
CHECKPOINT

Can anybody help me understand what is going on here?

View 1 Replies View Related

Loading Transaction Logs.....

Aug 11, 1999

I have a MS SQL Server 6.5/SP5A database running on NT 4.0/SP4 Enterprise Edition with MS Cluster Server. On my Production box, I dump the transaction logs every 30 minutes. I need to recreate a point in time on a separate TEST box with the same hardware/software. I created a "DBA database" from a previous night of Production - no problem. However, when I start applying the transaction logs, it complains about being out of sequence. The timestamps that it is reporting are accurate for the transaction logs, but it is basically using the database load time to compare it with. (Granted I am moving from one box to another, but I didn't think this would be a problem). I created a "DBA database" on Production, went through the same steps, and it takes the database load and the transaction logs. I am assuming that the sequence numbers on the transaction logs are identified internally on the file, not per server? Ideas as to why it would complain on an out of sequence condition (Error 4305) when I move to a different box?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved