Extract data from SQL DB

Hi All,
I am trying to:

  1. Run a stored procedure
  2. Use data from 2 columns to make a decision.

These are the column headers and i only need the data from “Type” and “Text”. the SQL result usually has 10-30 rows and I want to be able to check each row of column “Type” for a specific value.
Date TYPE SEQ_NUMBER STATUS TEXT

I have tried to use the “for each row” and I am not able to get it to work.

Hi
Welcome to uipath community
We will be able to iterate through each row using FOR EACH ROW activity
May I know the issue you were facing
Cheers @Nic_Karta

hello,

My work has asked me to analyse some data, but it is stored in SQL server so I am stuck and am hoping someone could help me please.
kamukta
I understand the basics of relational databases, so I can find the table I need, but of course a lot of the columns are full of IDs referencing other tables. What is the easiest way to get a copy of that table with all the IDs turned into the data they are referencing? So a copy of the Orders table with each CompanyName the actual name from the Company table etc?

I can do a SQL statement with a join (just about) but as the big table references lots of other tables, do I have to do one massive statement with a load of left joins? Or am I missing some simple command in SQL Server that would do it for me and pull in all referenced data?

I am not able to upload a screen print but here is what is happening. When I use the FOR EACH ROW and then a WRITE line, to output all the rows in column 2 I keep getting the same item in row 1, column 2 reapedly. Example:

H
H
H
H
H
H

but the SQL table has:
H
H
S
U
E
H

1 Like

Was it mentioned like this in Writeline activity
row(“yourcolumnname”).ToString
This would surely print each row value of the specified column
Cheers @Nic_Karta

I have this:

FOR EACH ROW
foreach [row] in [datatableName]

BODY
WRITE LINE
Text [row(TYPE - this is the name of the column).ToString

I get this error:

System Exception in: SQL_QUERY

: Column ‘H’ does not belong to table .

Write line : Column ‘H’ does not belong to table

1 Like

Kindly check whether the column name mentioned is there in the excel file
Or try with column index like 0 for first column
Like this
row(0).ToString //column index starts from 0 for first column

If possible can I have a view on the screenshot of both excel file and the input expression mentioned in the writeline activity

Cheers @Nic_Karta

Got it
Mention like this
Dt.Columns(1).ColumnName.ToString in the Type variable

Cheers @Nic_Karta

this is not Excel but a SQL output being read into memory

Then we can directly mention the column name as Type for second column
Like this inside the FOR EACH ROW loop
row(“Type”).ToString to get the value of Type column one by one
Cheers @Nic_Karta

this works as expected but i am now trying to do row(“Type”).ToString + row(“TEXT”).ToString to get 2 columns of Information but both columns are being joined and i need a space between the 2 columns.

THANK YOU, THANK YOU!!!

Like this

row(“Type”).ToString + “ “ + row(“TEXT”).ToString

Cheers @Nic_Karta

This works as expected. THANK YOU

1 Like

Cheers @Nic_Karta

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