I have a simple stored procedure that returns records:
Select empID, EmpFirstName, EmpLastName from EMPLOYEES
The returned result is:
EmpID EmpFirstName EmpLastName
----- ------------ -----------
30152 John Smith
30114 Tom Jones
56332 Steve Williams
85442 Paul Johnson
What I need is:
RecID EmpID EmpFirstName EmpLastName
----- ----- ------------ -----------
1 30152 John Smith
2 30114 Tom Jones
3 56332 Steve Williams
4 85442 Paul Johnson
How can I get the recordID column?
Thanks
Probably want to use Row_Number:
Select ROW_NUMBER() OVER(ORDER BY empID) AS RecId,
empID,
EmpFirstName,
EmpLastName
from EMPLOYEES
unless there is actually a RecId
column in EMPLOYEES
in which case it would just be this:
Select RecId,
empID,
EmpFirstName,
EmpLastName
from EMPLOYEES
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With