siva_sankar
(siva sankar)
December 22, 2021, 10:38am
#1
Hai,
I have to extract data from my SQL
Database is : client info
Table name is: production order
I need to extract data from SQL and stored in excel
1. I want Top 13 datas
2. I want bottom 5 datas only
How can I achieve this please explain me
Thanks & regards,
Sivasankar
lakshman
(Ganta lakshman)
December 22, 2021, 10:50am
#2
@siva_sankar
Use Execute Query query to fetch data from Database and it will give output as DataTable. And then use Write Range activity and pass above output DataTable to write into Excel file.
Hi @siva_sankar
How about Using below!
—> To take 13 datarows DT.AsEnumerable.Take(13).CopyToDatatable
---->To take last five datarows DT.AsEnumerable.skip(DT.Rows.count-5).CopyToDatatable**
Regards
3 Likes
siva_sankar
(siva sankar)
December 22, 2021, 11:29am
#4
Here Dt is mention as our sql tablename right
Hi @siva_sankar
Dt refers to the Datatable Which re you getting Out Dt from Using ExecuteQuery Activity!
Regards
1 Like
siva_sankar
(siva sankar)
December 22, 2021, 11:34am
#6
It’s through error like this
pikorpa
(Piotr Kołakowski)
December 22, 2021, 11:39am
#7
Hey,
in ‘sql’ field you have to use your sql query.
So use something like this:
Select top 15 *
from [production order]
1 Like
The SQL field in the activity property expects a String that contains your script.
For example:
“SELECT field1, field2, field3 FROM table”
I believe that the filters mentioned by other colleagues are applied after extracting information from the database to a DataTable type variable.
Your question is about how to filter the DataTable variable or how to make the script to extract data from the DB?
Hi @siva_sankar
For better understanding refer to the screenshot below!
Regards
1 Like
siva_sankar
(siva sankar)
December 22, 2021, 11:56am
#10
Can you provide that assign activit value from screenshot again I am getting error
@siva_sankar
Try Converting from string to datatable variable
and Use Write range to write the datatable
Regards
1 Like
siva_sankar
(siva sankar)
December 22, 2021, 12:07pm
#12
1 Like
system
(system)
closed
December 25, 2021, 12:07pm
#13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.