Write your stored procedure and then at the end put
SELECT @@IDENTITY
For example:
CREATE PROCEDURE TestProcedure
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO TestTable (column1, column2) VALUES ('test1', 'test2')
SELECT @@IDENTITY
END
If you are returning this to an application you are writing, you would change the SELECT @@IDENTIY to
SET @VariableName = SELECT @@IDENTITY