Sql uipath (update data)

Hi,

I am having a issue I need to loop through a series of records and update it on sql server however I am unsure how the looping is going to work

This is sequence of which I need to update the data

select distinct item_number, item_description from [dbo].[temp_InvoiceItems]
where item_number is null
or item_number = ‘’
or item_number = ‘NULL’

select distinct item_number
from [dbo].[temp_InvoiceItems]
where item_description = ‘10:1 MEAT’ (This is one item from the description however there is many)
and item_number is not null
and item_number <> ‘’
and item_number <> ‘NULL’

select * from [dbo].[temp_InvoiceItems]
where item_description = ‘10:1 MEAT’
and item_number = ‘NULL’

update [dbo].[temp_InvoiceItems]
set item_number = ‘5305’
where invoice_no = ‘INV000551198’
and item_description = ‘10:1 MEAT’

I have tried to find a way however I am unsure how I can loop through this for each record?

@Aki1111

You can use for each row in datatable if you have the data you what to filter in a datatable

Then inisde it …use like this

"select distinct item_number from [dbo].[temp_InvoiceItems] where item_description = ‘" + currenitem("ColumnName").ToString + "’ (This is one item from the description however there is many) and item_number is not null and item_number <> ‘’ and item_number <> ‘NULL’"

If editing the query in advanced editor then can include the variable as above …else add parameters and use parameters in the query

You can replicate same for all queries

Hope this helps

Cheers

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.