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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
pmscorca
Post Patron
Post Patron

Support for MERGE statement

Hi,

reading the documentation I've noticed the absence of the MERGE statement.

Does Fabric support this more important statement? Why not?

A such statement is very very important to work with a data warehouse!

In SQL Server I've used this statement, in Azure Synapse Analytics I've used this statement,

but I cannot find it in Fabric.

I hope that this feature could be released as soon as possible.

Many many thanks

1 ACCEPTED SOLUTION
tackytechtom
Super User
Super User

@pmscorca ,

 

I agree, it is a handy syntax.

 

It seems, MS is already working on it though 🙂

Microsoft Idea

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

3 REPLIES 3
tackytechtom
Super User
Super User

@pmscorca ,

 

I agree, it is a handy syntax.

 

It seems, MS is already working on it though 🙂

Microsoft Idea

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

tackytechtom
Super User
Super User

Hi @pmscorca ,

 

You are right, it seems ot be a current limitation:

T-SQL surface area - Microsoft Fabric | Microsoft Learn

 

However, you might be able to use another syntax than the merge statement, e.g. the code below:

MERGE INTO target_table AS target
USING source_table AS source
ON target.id = source.id
WHEN MATCHED THEN
    UPDATE SET 
        target.col1 = source.col1,
        target.col2 = source.col2
WHEN NOT MATCHED THEN
    INSERT (id, col1, col2)
    VALUES (source.id, source.col1, source.col2);

 

translates to:

UPDATE target_table
SET 
    target_table.col1 = source_table.col1,
    target_table.col2 = source_table.col2
FROM source_table
WHERE target_table.id = source_table.id; 

INSERT INTO target_table (id, col1, col2)
SELECT source_table.id, source_table.col1, source_table.col2
FROM source_table
LEFT JOIN target_table
ON source_table.id = target_table.id
WHERE target_table.id IS NULL; 

 

Let me know, if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Hi, thanks for your reply, but I know that it occurs to use an update and an insert statements when merge statement isn't available.

The focus of the post is about the merge statement ... having a such feature is very very important.

Thanks

Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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