Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
HamidBee
Power Participant
Power Participant

When to Use Pre-Copy Script vs. Source Query in Copy Activity?

Hello everyone,
 

I’m trying to get a better understanding of the Pre-Copy Script option in Microsoft Fabric's Copy Activity. Given that we already have the option to use a query to pull data from the source, I’m curious about the specific situations where the Pre-Copy Script comes in handy. Is it generally an either/or choice between using a query and a pre-copy script, or are there scenarios where it makes sense to use both within the same activity?

 

If anyone here actively uses the Pre-Copy Script, I’d love to hear about your experiences and the types of use cases where it’s proven helpful.

 

Thanks in advance!

1 ACCEPTED SOLUTION
FabianSchut
Super User
Super User

The difference between the query and the pre-copy script is that the query is performed on the source, while the pre-copy script is performed on the destination. You can use both within the same activity. You could for example delete all the records from the destination before you write new rows from the source to the destination that you've selected with your query.

View solution in original post

4 REPLIES 4
KGU_16031986
Regular Visitor

Pre-copy activity runs in a separate session, then copy command runs. both commands run on the destination. Please note, when pre-copy is used to delete rows then copy the records using the copy activity, there is a chance your destnation table loose data due to no rollback happense after delete if the copy activity fails. This is a situation that we must aware when use truncate or delete in pre-copy activity and this answers my own question. 
Thanks!!

KGU_16031986
Regular Visitor

Precopy command and coppy command on the destination runs in  a same session or in two sessions? 
Are there any chances we loose data when pre-copy success and copy command fail ? 

 

MonicaCVL
Advocate I
Advocate I

Hi @HamidBee 

The Pre-Copy Script in Microsoft Fabric’s Copy Activity is useful for tasks like cleaning up old data, making schema adjustments, preparing data, or implementing conditional logic before copying new data. It can be used alongside a query to ensure both the source data and destination environment are properly managed.

with regards

Monica CVL

FabianSchut
Super User
Super User

The difference between the query and the pre-copy script is that the query is performed on the source, while the pre-copy script is performed on the destination. You can use both within the same activity. You could for example delete all the records from the destination before you write new rows from the source to the destination that you've selected with your query.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

Top Solution Authors