Just as a follow-up...if you want to wrap all this up in a stored procedure, there was a discussion about this a few months ago. Check out message #930339 from Bonnie Berent.
If all you want to do is run a subsequent query, then the scope_identity should work.