cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
jeremy_brown
Level: Powered On

Get single row from SQL Server

Does anyone have any tips on getting a single row from a table in a sql database?

There are two connectors I see. One for ‘Get Row’ which seems like it only takes an actual row number, which isn’t really helpful. The other is ‘Get Rows’ which I can easily pass what I need to it and only have it return one row, but then I have to loop through that data to get the data I need.
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Get single row from SQL Server

Hi @jeremy_brown,

 

Could you please share a screenshot of your flow's configuration?

Could you please show a bit more about your scenario?

Further, do you want to get a single row without using the "Apply to each" action?

 

The output of the "Get items" action is an array, so when you reference the Dynamic contents of the "Get items" action within following steps, the flow would add a "Apply to each" action automatically, even though the output of the "Get items" action only contains one row.

 

If you want to get the single row from the "Get items" action without using a "Apply to each" action, please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a "Get rows" action, specify Table name. Within Filter Query field, type the following formula:
Email eq 'Test1@xxxxxx.onmicrosoft.com'

Note: The Email is a column in my SQL table and each row have a unique Email value.

  • Add a "Compose" action, Inputs set to following formula:
first(body('Get_rows')?['value'])

Image reference:9.JPG

The flow works successfully as below:10.JPG

 

In addition, if you want to reference the column values within that single row (as above screenshot), you could consider take a try with the following formula:

outputs('Compose')?['ContactName']

On your side, you should type the following formula:

outputs('Compose')?['ColumnNameOfYourSQLTable']

11.JPG

The flow works successfully as below:

 12.JPG

 

More details about using expression in flow actions, please check the following article:

Use expression in flow actions

 

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: Get single row from SQL Server

Hi @jeremy_brown,

 

Could you please share a screenshot of your flow's configuration?

Could you please show a bit more about your scenario?

Further, do you want to get a single row without using the "Apply to each" action?

 

The output of the "Get items" action is an array, so when you reference the Dynamic contents of the "Get items" action within following steps, the flow would add a "Apply to each" action automatically, even though the output of the "Get items" action only contains one row.

 

If you want to get the single row from the "Get items" action without using a "Apply to each" action, please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a "Get rows" action, specify Table name. Within Filter Query field, type the following formula:
Email eq 'Test1@xxxxxx.onmicrosoft.com'

Note: The Email is a column in my SQL table and each row have a unique Email value.

  • Add a "Compose" action, Inputs set to following formula:
first(body('Get_rows')?['value'])

Image reference:9.JPG

The flow works successfully as below:10.JPG

 

In addition, if you want to reference the column values within that single row (as above screenshot), you could consider take a try with the following formula:

outputs('Compose')?['ContactName']

On your side, you should type the following formula:

outputs('Compose')?['ColumnNameOfYourSQLTable']

11.JPG

The flow works successfully as below:

 12.JPG

 

More details about using expression in flow actions, please check the following article:

Use expression in flow actions

 

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

jeremy_brown
Level: Powered On

Re: Get single row from SQL Server

@v-xida-msft that worked perfectly.  I will probably use a combination of Compose and maybe Parse JSON to hold my entire table row.  This makes what I was doing so much simpler/cost effect. 

 

Thanks!

 

MichelH
Level 8

Re: Get single row from SQL Server

I was surprised to find MS Flow does not allow me to specify the column name in the 'get row' for which I have a unique value.

 

As if they were only having a spreadsheet in mind when designing this.  😕

 

I guess this workaround (thank you Kris), is as good as it gets, but it does make the resuting flow less clear for another person who needs to maintain it later.

 

Thanks to all for their input here.

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,636)