>Then how is the nnid returned to the user?
@nnid is a variable. You have three choices for returning it from a stored procedure:
1 - as a recordset
SELECT @nnid
2 - in an output parameter
CREATE PROCEDURE nextid
@token varchar(10), @nnid integer OUTPUT
3 - As a return value
RETURN @nnid
(not recommended. By convention, the return value of a stored procedure is used to indicate status)
-Mike