web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Writing from Excel to ...
Power Automate
Answered

Writing from Excel to SQL - Error on primary key

(0) ShareShare
ReportReport
Posted on by 2

Hello everybody,

 

I'm currently writing a flow that needs to read an Excel file (Raw log data) into a SQL database.

 

For this I have constructed the following flow (In dutch):

MaxPost_0-1622126864106.png

(1. Open Excel

2. Find first free row

3. Read all Excel rows up to first free row

4. Connect SQL database

5. For reach row in Excel execute Stored Procedure 'SP_Uitvoer'

6. Close SQL connection

7. Close Excel)

 

This flow will work the first time, when there is not data in the SQL database yet. The problem is that when I execute the flow again, the error 'can not insert duplicate primary key' comes up. This makes sense, because currently I'm telling Power Automate to insert all values from the log file again.

 

What I want to do but don't seem to be able to figure out, is to only add in the new rows into the database. 

If anyone could enlighten me on how to do this, that would be marvelous! 🙂 

 

For good measure, the Stored Procedure looks like this:

MaxPost_0-1622127320104.png

 

 

 

I have the same question (0)
  • Verified answer
    Henrik_M Profile Picture
    2,021 Super User 2024 Season 1 on at

    I think you need to modify your query with some IF NOT EXISTS stuff.

    Check it out: SQL Server Insert if not exists - Stack Overflow 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 796

#2
Valantis Profile Picture

Valantis 568

#3
Haque Profile Picture

Haque 538

Last 30 days Overall leaderboard