I appreciate everyone sticking with me on this.
Aart, I changed the last line as you suggested.
Arnd, I hate to say this, but I did not know how to test the sp. I googled it and it was quite easy to test and it helpfully pointed out some errors that I fixed.
I now know the stored procedure works. Here are the nice automatically generated sql statements that SQL Management Studio created for me:
USE [LIMO]
GO
DECLARE @return_value int,
@rate_rank int
EXEC @return_value = [dbo].[ft_sp_RankAffiliateRate5]
@sp_id = N'F10968',
@a_identity = 23864,
@b_identity = 4018,
@vehicle_type = 1,
@rate_rank = @rate_rank OUTPUT
SELECT @rate_rank as N'@rate_rank'
SELECT 'Return Value' = @return_value
GO
I know some of you have suggested replacing the datawindow syntax with one overarching sql statement that includes the rank_dense clause as a subselect. I will do that if it appears that there are performance problems.
For the moment, I am going to focus on getting it running from a PB script and see if there is a performance problem.
So right now, I am thinking maybe I can just execute the sql as shown above and get @return_value.
Thanks again everyone!!!!!
Paul