I am still not very sure what you want to store because you said something about syntax error.
I had created a error table before to store the errors of some of my procedures.
CREATE TABLE Err_Table (ErrID INT IDENTITY(1,1) NOT NULL,
ProcedureName VARCHAR(250) NOT NULL,
ErrorDesc VARCHAR(250) NOT NULL,
ErrorLogTime DATETIME NOT NULL)
In the procedure that you want to capture the error, you just need to insert data into the table.
For example if the select statement has an error or it returns 0 record when you expect it should return data.
DECLARE @Error INT, @Rowcount INT
SELECT .... FROM ....
SELECT @Error = @@ERROR, @Rowcount = @@ROWCOUNT
IF @Error <> 0
INSERT INTO Err_table (ProcedureName, ErrorDesc, ErrorLogTIme) SELECT 'procedure', 'SELECT ...Statement returned error', GETDATE()
IF @Rowcount = 0