GO isn't a TSQL command. It marks the end of a batch in Query Analyzer and
therefore signals the end of a stored procedure definition in that batch, so
it should not be part of an SP.
NOTE : I assumed that three calls are independent of each other and that is why error handling is seperate...
CREATE PROCEDURE ALLinone
(
@Sname varchar(50),
@Srollno varchar(50),
@Pname varchar(50),
@Saddr varchar(50)
)
AS
BEGIN
CREATE TABLE #Errors (ErrAt NVARCHAR(20), ErrNumber INT, ErrorMessage NVARCHAR(MAX))
BEGIN TRY
EXEC SP_Testone @Sname, @Srollno
END TRY
BEGIN CATCH
INSERT #Errors
SELECT 'SP_Testone', ERROR_NUMBER(), ERROR_MESSAGE()
END CATCH;
BEGIN TRY
EXEC SP_Testtwo @Sname, @Pname
END TRY
BEGIN CATCH
INSERT #Errors
SELECT 'SP_Testtwo', ERROR_NUMBER(), ERROR_MESSAGE()
END CATCH;
BEGIN TRY
EXEC SP_Testthree @Sname, @Pname
END TRY
BEGIN CATCH
INSERT #Errors
SELECT 'SP_Testthree', ERROR_NUMBER(), ERROR_MESSAGE()
END CATCH;
SELECT * FROM #Errors
END