Good morning. I need some help. I need to pass two fields into (eventually) a combo box. In order to handle the user selection, I need to have a description field (strReferredDiv) and an index (RowNum). I have a class that can accept a sql statement and loop through and marshal the data to my UI front end classes which load into the combo box.
The problem I am having is for the situation that I don't have a field for my index field to use. (This is within a criteria reporting form) So I would like to formulate a Transact SQL statement that gives me my fields. RowNum (increments a counter for each row), description (strReferredDiv, in my sample). Any Ideas?
My sample
doesn't increment the @intVar for each record.
/********************/
declare @intVar int
select @intVar = 0
select (@intvar + 1) RowNum, strReferredDiv
from tblActionRequest
group by strReferredDiv
Order by RowNum
/********************/
RETURNS
RowNum strReferredDiv
----------- ----------------------------------------
1 Information Services
1 Solid Waste
1 Street Maintenance
1 Transportation Administration
When I would like it to return:
RowNum strReferredDiv
----------- ----------------------------------------
1 Information Services
2 Solid Waste
3 Street Maintenance
4 Transportation Administration
The problem I am having is for the situation that I don't have a field for my index field to use. (This is within a criteria reporting form) So I would like to formulate a Transact SQL statement that gives me my fields. RowNum (increments a counter for each row), description (strReferredDiv, in my sample). Any Ideas?
My sample
doesn't increment the @intVar for each record.
/********************/
declare @intVar int
select @intVar = 0
select (@intvar + 1) RowNum, strReferredDiv
from tblActionRequest
group by strReferredDiv
Order by RowNum
/********************/
RETURNS
RowNum strReferredDiv
----------- ----------------------------------------
1 Information Services
1 Solid Waste
1 Street Maintenance
1 Transportation Administration
When I would like it to return:
RowNum strReferredDiv
----------- ----------------------------------------
1 Information Services
2 Solid Waste
3 Street Maintenance
4 Transportation Administration