Best answer

How to retrieve all rows matching a specific parameter in a MS SQL database column with Zapier?

Show first post

79 replies

Userlevel 1

I’ve figured out quite a simple workaround for this.

Firstly you need to run a Find Row via Custom Query in SQL Server statement that selects the key of each of the elements in your list. So if you imagine your table called FOOD is like this:


and you want to loop through all the elements that are type ‘Hot’

Run a SQL Select that looks like this:

select replace((stuff((select ',' + str(id) FROM Food where type = ‘Hot’ FOR XML PATH('')),1,1,'')), ' ', '') as ID

That will return a single element with the value ‘2,3’

You then use Create a Loop from Text that loops through each id in the results from above in turn with the sub loop elements able to reference each Key (Id) value in turn so you can update, or read or whatever using other SQL functions.

A limitation to this approach is Loops don't work in sub-zaps and loop have to be at the end of a zap. So it works if you have a discrete process to run on multiple records, but not if you want to process multiple records and then continue on to do something else within the same zap.

Userlevel 7
Badge +11

Sorry to hear Mark B’s suggestion won’t work for your Zaps @MortEdBrad. I can totally understand how disappointing it must be to wait this long for this feature to be added. And I really wish I was writing back with better news but we can't commit to any timeline or give any guarantee as to when this feature request would be implemented. It appears our Support team had previously added your vote though which will allow us to notify you via email once it’s added.

@asg3 - Ah, yes if you’re specifically wanting to loop through items in a Sub-Zap and then send that to another Zap it wouldn’t work as you can’t add a loop action step in before a Return from Sub-Zap action step. If we come across any alternative workarounds we’ll be sure to share them here. Sorry to not have a more immediate solution on this right now.  

Is this still not solved? 

Userlevel 7
Badge +11

Hi @isaiah_p 👋

I’ve just checked again and it’s still not been added yet. I’ve added your vote which helps to bump up it’s priority but I can’t give an estimate on when you can expect it to become available. 

Thanks for everyone’s continued patience here. We’ll keep this thread updated with and additional updates or workarounds we come across in the meantime!