cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jeremy_brown
Frequent Visitor

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
v-xida-msft
Community Support
Community Support

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
v-xida-msft
Community Support
Community Support

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
Frequent Visitor

@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!

 

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,058)