insert incremental row number in a calculated query field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can I add a calculated field to an adp query which will automatically provide
an incrementing value for each row (starting at 1) ?
 
Hello Jason,

I understand that you'd like to add row number field in a ADP query. If I'm
off-base, please let's know.

If the original query is following in northwind ADP sample database:

SELECT OrderID, EmployeeID FROM dbo.Orders order by orderid asc


You could use the following SP to get the rownumber of the query with an
additional field.


ALTER PROCEDURE dbo.testrownumber
AS SELECT OrderID, EmployeeID, (select count(*) from dbo.Orders o2
where o2.orderid <=o.orderid ) as rownumber
FROM dbo.Orders o order by orderid asc

In design view of SP, you could select View->SQL View to see sql query view
directly.

If you have further questions or comments on the issue, please feel free to
let's know. Thank you.


Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
<http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
<http://msdn.microsoft.com/subscriptions/support/default.aspx>.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hello Jason,

My Pleasure. :-)

Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support


=====================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 
Back
Top