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 / how to assign null val...
Power Automate
Unanswered

how to assign null value in Insert Row (V2) for MS SQL server by using if statement

(0) ShareShare
ReportReport
Posted on by 36

Hi,

 

How can I assign null to a varchar field in MS SQL using "Insert Row (V2)" action by checking a condition.

 

In the below example, I have a simple table (WCC_Testing) having 2 data fields. 

KinsonLam_0-1719282420616.png

 

 

When I directly put @{null} in the data field, it is correctly assigned NULL into the table.

KinsonLam_1-1719282420798.png

 

KinsonLam_2-1719282420586.png

 

 

However, if I use @{if()} to evaluate and then assign null, it inserts empty string rather than NULL to the table. 

If this case, I have a variable 'vTest' with initial value @{null}, then in the insert row action, I put @{

if (empty(variables('vText')), null, variables('vText'))}, trying to assign null to the datafield.  However, it is not a NULL in database but empty string.

KinsonLam_3-1719282420793.png

 

KinsonLam_4-1719282420611.png

 

 

I would like to put NULL in database base on the evaluation result in the if statement.  What's wrong and how to fix it?

 

Thanks for any help.

Categories:
I have the same question (0)
  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @Kinson-Lam 

    As i test it in my side , i use the same expression as yours.

    vyueyunmsft_1-1719283899915.png

     

    It can work in my side , can you try to convert to the classic mode in Power Automate and re-create a action and try again?

    vyueyunmsft_0-1719283777835.png

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

     

  • Kinson-Lam (WCC) Profile Picture
    36 on at

    Hi, Zhang,

     

    I have switched back to classic mode as below,

    KinsonLam_0-1719378474885.png

     

    However, after run, the TestCode is still not NULL in database after using the if-statement.  But it will be NULL is I assign @{null} directly.  Any idea?

    KinsonLam_1-1719378553689.png

     

    Any idea?

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