dbTalk Databases Forums  

Getting value from last row in dataflow.

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Getting value from last row in dataflow. in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Yuriy Al
 
Posts: n/a

Default Getting value from last row in dataflow. - 06-16-2008 , 08:04 PM






I have dataflow where rows are moved from OLEDB source to OLEDB destination
by bulks defined in dynamically generated select statement within source.
SELECT TOP @batch_size Col1, Col2, Col3
FROM Table1
ORDER BY Col1

The requirement is to save the Col1 value of the last row. Theonly solution
I found in Internet is to direct dataflow to Recordset destination, and then
in ControlFlow continue to ForEachLoop over the recordset, using mapped
variable. The biggest concern here is a preformance.

Does anybody have any experience with similar king of task?
Any suggestions/ideas are much appreciated.


Thanks,
Yuriy

Reply With Quote
  #2  
Old   
Todd C
 
Posts: n/a

Default RE: Getting value from last row in dataflow. - 06-17-2008 , 07:49 AM






Hello Yuriy:

Seems to me you can get this value using an Execute SQL Task on your Control
Flow:
SELECT MAX(Col1) FROM
(SELECT TOP @batch_Size) Col1
FROM Table1
ORDER BY Col1) AS x

Set the Result Set of the task to single row, and in the ResultSet page, add
a mapping, named 0 to a new package varialbe.

--
Todd C

[If this response was helpful, please indicate by clicking the appropriate
answer at the bottom]


"Yuriy Al" wrote:

Quote:
I have dataflow where rows are moved from OLEDB source to OLEDB destination
by bulks defined in dynamically generated select statement within source.
SELECT TOP @batch_size Col1, Col2, Col3
FROM Table1
ORDER BY Col1

The requirement is to save the Col1 value of the last row. Theonly solution
I found in Internet is to direct dataflow to Recordset destination, and then
in ControlFlow continue to ForEachLoop over the recordset, using mapped
variable. The biggest concern here is a preformance.

Does anybody have any experience with similar king of task?
Any suggestions/ideas are much appreciated.


Thanks,
Yuriy

Reply With Quote
  #3  
Old   
Todd C
 
Posts: n/a

Default RE: Getting value from last row in dataflow. - 06-17-2008 , 07:49 AM



Hello Yuriy:

Seems to me you can get this value using an Execute SQL Task on your Control
Flow:
SELECT MAX(Col1) FROM
(SELECT TOP @batch_Size) Col1
FROM Table1
ORDER BY Col1) AS x

Set the Result Set of the task to single row, and in the ResultSet page, add
a mapping, named 0 to a new package varialbe.

--
Todd C

[If this response was helpful, please indicate by clicking the appropriate
answer at the bottom]


"Yuriy Al" wrote:

Quote:
I have dataflow where rows are moved from OLEDB source to OLEDB destination
by bulks defined in dynamically generated select statement within source.
SELECT TOP @batch_size Col1, Col2, Col3
FROM Table1
ORDER BY Col1

The requirement is to save the Col1 value of the last row. Theonly solution
I found in Internet is to direct dataflow to Recordset destination, and then
in ControlFlow continue to ForEachLoop over the recordset, using mapped
variable. The biggest concern here is a preformance.

Does anybody have any experience with similar king of task?
Any suggestions/ideas are much appreciated.


Thanks,
Yuriy

Reply With Quote
  #4  
Old   
Todd C
 
Posts: n/a

Default RE: Getting value from last row in dataflow. - 06-17-2008 , 07:49 AM



Hello Yuriy:

Seems to me you can get this value using an Execute SQL Task on your Control
Flow:
SELECT MAX(Col1) FROM
(SELECT TOP @batch_Size) Col1
FROM Table1
ORDER BY Col1) AS x

Set the Result Set of the task to single row, and in the ResultSet page, add
a mapping, named 0 to a new package varialbe.

--
Todd C

[If this response was helpful, please indicate by clicking the appropriate
answer at the bottom]


"Yuriy Al" wrote:

Quote:
I have dataflow where rows are moved from OLEDB source to OLEDB destination
by bulks defined in dynamically generated select statement within source.
SELECT TOP @batch_size Col1, Col2, Col3
FROM Table1
ORDER BY Col1

The requirement is to save the Col1 value of the last row. Theonly solution
I found in Internet is to direct dataflow to Recordset destination, and then
in ControlFlow continue to ForEachLoop over the recordset, using mapped
variable. The biggest concern here is a preformance.

Does anybody have any experience with similar king of task?
Any suggestions/ideas are much appreciated.


Thanks,
Yuriy

Reply With Quote
  #5  
Old   
Todd C
 
Posts: n/a

Default RE: Getting value from last row in dataflow. - 06-17-2008 , 07:49 AM



Hello Yuriy:

Seems to me you can get this value using an Execute SQL Task on your Control
Flow:
SELECT MAX(Col1) FROM
(SELECT TOP @batch_Size) Col1
FROM Table1
ORDER BY Col1) AS x

Set the Result Set of the task to single row, and in the ResultSet page, add
a mapping, named 0 to a new package varialbe.

--
Todd C

[If this response was helpful, please indicate by clicking the appropriate
answer at the bottom]


"Yuriy Al" wrote:

Quote:
I have dataflow where rows are moved from OLEDB source to OLEDB destination
by bulks defined in dynamically generated select statement within source.
SELECT TOP @batch_size Col1, Col2, Col3
FROM Table1
ORDER BY Col1

The requirement is to save the Col1 value of the last row. Theonly solution
I found in Internet is to direct dataflow to Recordset destination, and then
in ControlFlow continue to ForEachLoop over the recordset, using mapped
variable. The biggest concern here is a preformance.

Does anybody have any experience with similar king of task?
Any suggestions/ideas are much appreciated.


Thanks,
Yuriy

Reply With Quote
  #6  
Old   
Todd C
 
Posts: n/a

Default RE: Getting value from last row in dataflow. - 06-17-2008 , 07:49 AM



Hello Yuriy:

Seems to me you can get this value using an Execute SQL Task on your Control
Flow:
SELECT MAX(Col1) FROM
(SELECT TOP @batch_Size) Col1
FROM Table1
ORDER BY Col1) AS x

Set the Result Set of the task to single row, and in the ResultSet page, add
a mapping, named 0 to a new package varialbe.

--
Todd C

[If this response was helpful, please indicate by clicking the appropriate
answer at the bottom]


"Yuriy Al" wrote:

Quote:
I have dataflow where rows are moved from OLEDB source to OLEDB destination
by bulks defined in dynamically generated select statement within source.
SELECT TOP @batch_size Col1, Col2, Col3
FROM Table1
ORDER BY Col1

The requirement is to save the Col1 value of the last row. Theonly solution
I found in Internet is to direct dataflow to Recordset destination, and then
in ControlFlow continue to ForEachLoop over the recordset, using mapped
variable. The biggest concern here is a preformance.

Does anybody have any experience with similar king of task?
Any suggestions/ideas are much appreciated.


Thanks,
Yuriy

Reply With Quote
  #7  
Old   
Todd C
 
Posts: n/a

Default RE: Getting value from last row in dataflow. - 06-17-2008 , 07:49 AM



Hello Yuriy:

Seems to me you can get this value using an Execute SQL Task on your Control
Flow:
SELECT MAX(Col1) FROM
(SELECT TOP @batch_Size) Col1
FROM Table1
ORDER BY Col1) AS x

Set the Result Set of the task to single row, and in the ResultSet page, add
a mapping, named 0 to a new package varialbe.

--
Todd C

[If this response was helpful, please indicate by clicking the appropriate
answer at the bottom]


"Yuriy Al" wrote:

Quote:
I have dataflow where rows are moved from OLEDB source to OLEDB destination
by bulks defined in dynamically generated select statement within source.
SELECT TOP @batch_size Col1, Col2, Col3
FROM Table1
ORDER BY Col1

The requirement is to save the Col1 value of the last row. Theonly solution
I found in Internet is to direct dataflow to Recordset destination, and then
in ControlFlow continue to ForEachLoop over the recordset, using mapped
variable. The biggest concern here is a preformance.

Does anybody have any experience with similar king of task?
Any suggestions/ideas are much appreciated.


Thanks,
Yuriy

Reply With Quote
  #8  
Old   
Todd C
 
Posts: n/a

Default RE: Getting value from last row in dataflow. - 06-17-2008 , 07:49 AM



Hello Yuriy:

Seems to me you can get this value using an Execute SQL Task on your Control
Flow:
SELECT MAX(Col1) FROM
(SELECT TOP @batch_Size) Col1
FROM Table1
ORDER BY Col1) AS x

Set the Result Set of the task to single row, and in the ResultSet page, add
a mapping, named 0 to a new package varialbe.

--
Todd C

[If this response was helpful, please indicate by clicking the appropriate
answer at the bottom]


"Yuriy Al" wrote:

Quote:
I have dataflow where rows are moved from OLEDB source to OLEDB destination
by bulks defined in dynamically generated select statement within source.
SELECT TOP @batch_size Col1, Col2, Col3
FROM Table1
ORDER BY Col1

The requirement is to save the Col1 value of the last row. Theonly solution
I found in Internet is to direct dataflow to Recordset destination, and then
in ControlFlow continue to ForEachLoop over the recordset, using mapped
variable. The biggest concern here is a preformance.

Does anybody have any experience with similar king of task?
Any suggestions/ideas are much appreciated.


Thanks,
Yuriy

Reply With Quote
  #9  
Old   
Todd C
 
Posts: n/a

Default RE: Getting value from last row in dataflow. - 06-17-2008 , 07:49 AM



Hello Yuriy:

Seems to me you can get this value using an Execute SQL Task on your Control
Flow:
SELECT MAX(Col1) FROM
(SELECT TOP @batch_Size) Col1
FROM Table1
ORDER BY Col1) AS x

Set the Result Set of the task to single row, and in the ResultSet page, add
a mapping, named 0 to a new package varialbe.

--
Todd C

[If this response was helpful, please indicate by clicking the appropriate
answer at the bottom]


"Yuriy Al" wrote:

Quote:
I have dataflow where rows are moved from OLEDB source to OLEDB destination
by bulks defined in dynamically generated select statement within source.
SELECT TOP @batch_size Col1, Col2, Col3
FROM Table1
ORDER BY Col1

The requirement is to save the Col1 value of the last row. Theonly solution
I found in Internet is to direct dataflow to Recordset destination, and then
in ControlFlow continue to ForEachLoop over the recordset, using mapped
variable. The biggest concern here is a preformance.

Does anybody have any experience with similar king of task?
Any suggestions/ideas are much appreciated.


Thanks,
Yuriy

Reply With Quote
  #10  
Old   
Yuriy Al
 
Posts: n/a

Default RE: Getting value from last row in dataflow. - 06-17-2008 , 08:15 AM



Thank you for the answer.
Yes, it is possible, but it will require SQL task to connect to the
destination and read the table. I am trying to avoid this as in large
environment it has performance impact. It is better to read value within
dataflow, as rows are already loaded from the table.

Thanks,
Yuriy



"Todd C" wrote:

Quote:
Hello Yuriy:

Seems to me you can get this value using an Execute SQL Task on your Control
Flow:
SELECT MAX(Col1) FROM
(SELECT TOP @batch_Size) Col1
FROM Table1
ORDER BY Col1) AS x

Set the Result Set of the task to single row, and in the ResultSet page, add
a mapping, named 0 to a new package varialbe.

--
Todd C

[If this response was helpful, please indicate by clicking the appropriate
answer at the bottom]


"Yuriy Al" wrote:

I have dataflow where rows are moved from OLEDB source to OLEDB destination
by bulks defined in dynamically generated select statement within source.
SELECT TOP @batch_size Col1, Col2, Col3
FROM Table1
ORDER BY Col1

The requirement is to save the Col1 value of the last row. Theonly solution
I found in Internet is to direct dataflow to Recordset destination, and then
in ControlFlow continue to ForEachLoop over the recordset, using mapped
variable. The biggest concern here is a preformance.

Does anybody have any experience with similar king of task?
Any suggestions/ideas are much appreciated.


Thanks,
Yuriy

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.