![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Specifically for DTS or in a query generally? In a SQL query a "row number" normally means a "ranking" or "sequence" based on some sort order. For example, here's a query for a row number based on au_id: SELECT au_id, au_lname, au_fname, (SELECT COUNT(*) FROM pubs.dbo.authors WHERE au_id <= A.au_id) AS row_no FROM pubs.dbo.authors AS A ORDER BY au_id ; Run this both with and without the ORDER BY to demonstrate that the row_no is derived in the subquery - it has nothing to do with the displayed order or some notional ordering in the table because no such order exists for the query itself. In DTS, when transforming a non-relational data source such as a text file you may want to include an incrementing row number in the transformation. To do this, you can create a global variable and then add the following lines to the ActiveX row transform: DTSGlobalVariables("row_no").Value = DTSGlobalVariables("row_no").Value + 1 ... DTSDestination("row_no") = DTSGlobalVariables("row_no").Value Hope this helps. -- David Portas SQL Server MVP -- |
![]() |
| Thread Tools | |
| Display Modes | |
| |