Showing posts with label clear. Show all posts
Showing posts with label clear. Show all posts

Thursday, March 22, 2012

Deleting Existing Data before Loading New Data

I have a package which loads data from a flat file (csv) to 4 tables in a database.
Now, the load is incremental.

I want to clear the data of all 4 tables(in the database) before loading the data from flat file everytime.How can i do this?
Iam using 4 Oledb Destinations, 1 multicast, 1 source component to do this.
Also can it happen like a transaction? because if it deletes the existing data and couldnt load new data there will be a problem!.how to avoid this?

anils wrote:

I have a package which loads data from a flat file (csv) to 4 tables in a database.
Now, the load is incremental.

I want to clear the data of all 4 tables(in the database) before loading the data from flat file everytime.How can i do this?

In the control flow, use an ExecuteSQL Task to call TRUNCATE (or DELETE FROM) each of the tables you want to purge, before calling the Data Flow task.
|||The load doesn't sound incremental. It sounds like you are doing "drop and replace". If you want to do incremental, you should use lookups to check the destination to see if the row already exists, and only insert the ones that don't.

If you do want to drop and replace and allow rollback if the replace fails, then you need to enable transactions. First create an Execute SQL task(s) to delete your data before the Data Flow that loads the new data. Determine or create a container that will have the same scope as the transaction you want to create. If there are no other tasks in your control flow, then the package can be the container. Otherwise you can add a Sequence Container to hold the tasks that will be part of the transaction. On the container change the TransactionOption to "Required". Make sure it remains the default "Supported" for each task. Now if the Data Flow fails for some reason, the deletes will be rolled back.

|||Thanks JayH for the reply.

"If you want to do incremental, you should use lookups to check the destination to see if the row already exists, and only insert the ones that don't"

Could You please explain in detail on how to do this?
|||

anils wrote:

Thanks JayH for the reply.

"If you want to do incremental, you should use lookups to check the destination to see if the row already exists, and only insert the ones that don't"

Could You please explain in detail on how to do this?

You can use the Lookup component to find rows that don't exist in your destination table by redirecting the row on a lookup failure. See Method #2 of this article: http://www.sqlis.com/311.aspx

If you need to detect changes and not just new rows, then it becomes trickier and you may find this helpful: http://blogs.conchango.com/jamiethomson/archive/2006/09/12/SSIS_3A00_-Checking-if-a-row-exists-and-if-it-does_2C00_-has-it-changed.aspx

Friday, February 24, 2012

delete remnants of log shipping

I deleted all the maintenance plans but somehow the log shipping monitor
showing the log shipping pair still remains. How can i clear all the log
shipping ?
Log shipping can be removed from the Maintenance Wizard. Is that where you
removed log shipping? Run the wizard and when you get to the Log Shipping
tab, click on Remove Log Shipping.
To remove a Log Shipping pair from the monitor, use
sp_delete_log_shipping_monitor_info. This is discussed in detail in BOL so
do a search and you'll find all you need.
joe.
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:eLoO1N4UFHA.3292@.TK2MSFTNGP14.phx.gbl...
>I deleted all the maintenance plans but somehow the log shipping monitor
> showing the log shipping pair still remains. How can i clear all the log
> shipping ?
>
|||Not that MS supports hacking system tables, but msdb..log_shipping_monitor is
where this info is stored.
If the stored proc doesn't work, I've had to restort to cleaning this out
manually.
DO this at your own risk.
<standard disclaimer inserted here>
Donna Lambert
"Joe Yong" wrote:

> Log shipping can be removed from the Maintenance Wizard. Is that where you
> removed log shipping? Run the wizard and when you get to the Log Shipping
> tab, click on Remove Log Shipping.
> To remove a Log Shipping pair from the monitor, use
> sp_delete_log_shipping_monitor_info. This is discussed in detail in BOL so
> do a search and you'll find all you need.
>
> joe.
>
> "Hassan" <fatima_ja@.hotmail.com> wrote in message
> news:eLoO1N4UFHA.3292@.TK2MSFTNGP14.phx.gbl...
>
>

delete remnants of log shipping

I deleted all the maintenance plans but somehow the log shipping monitor
showing the log shipping pair still remains. How can i clear all the log
shipping ?Log shipping can be removed from the Maintenance Wizard. Is that where you
removed log shipping? Run the wizard and when you get to the Log Shipping
tab, click on Remove Log Shipping.
To remove a Log Shipping pair from the monitor, use
sp_delete_log_shipping_monitor_info. This is discussed in detail in BOL so
do a search and you'll find all you need.
joe.
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:eLoO1N4UFHA.3292@.TK2MSFTNGP14.phx.gbl...
>I deleted all the maintenance plans but somehow the log shipping monitor
> showing the log shipping pair still remains. How can i clear all the log
> shipping ?
>|||Not that MS supports hacking system tables, but msdb..log_shipping_monitor is
where this info is stored.
If the stored proc doesn't work, I've had to restort to cleaning this out
manually.
DO this at your own risk.
<standard disclaimer inserted here>
Donna Lambert
"Joe Yong" wrote:
> Log shipping can be removed from the Maintenance Wizard. Is that where you
> removed log shipping? Run the wizard and when you get to the Log Shipping
> tab, click on Remove Log Shipping.
> To remove a Log Shipping pair from the monitor, use
> sp_delete_log_shipping_monitor_info. This is discussed in detail in BOL so
> do a search and you'll find all you need.
>
> joe.
>
> "Hassan" <fatima_ja@.hotmail.com> wrote in message
> news:eLoO1N4UFHA.3292@.TK2MSFTNGP14.phx.gbl...
> >I deleted all the maintenance plans but somehow the log shipping monitor
> > showing the log shipping pair still remains. How can i clear all the log
> > shipping ?
> >
> >
>
>

Sunday, February 19, 2012

delete remnants of log shipping

I deleted all the maintenance plans but somehow the log shipping monitor
showing the log shipping pair still remains. How can i clear all the log
shipping ?Log shipping can be removed from the Maintenance Wizard. Is that where you
removed log shipping? Run the wizard and when you get to the Log Shipping
tab, click on Remove Log Shipping.
To remove a Log Shipping pair from the monitor, use
sp_delete_log_shipping_monitor_info. This is discussed in detail in BOL so
do a search and you'll find all you need.
joe.
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:eLoO1N4UFHA.3292@.TK2MSFTNGP14.phx.gbl...
>I deleted all the maintenance plans but somehow the log shipping monitor
> showing the log shipping pair still remains. How can i clear all the log
> shipping ?
>|||Not that MS supports hacking system tables, but msdb..log_shipping_monitor i
s
where this info is stored.
If the stored proc doesn't work, I've had to restort to cleaning this out
manually.
DO this at your own risk.
<standard disclaimer inserted here>
Donna Lambert
"Joe Yong" wrote:

> Log shipping can be removed from the Maintenance Wizard. Is that where you
> removed log shipping? Run the wizard and when you get to the Log Shipping
> tab, click on Remove Log Shipping.
> To remove a Log Shipping pair from the monitor, use
> sp_delete_log_shipping_monitor_info. This is discussed in detail in BOL so
> do a search and you'll find all you need.
>
> joe.
>
> "Hassan" <fatima_ja@.hotmail.com> wrote in message
> news:eLoO1N4UFHA.3292@.TK2MSFTNGP14.phx.gbl...
>
>