Hello!
I got a few stored procedures that uses a TRY/CATCH statement, so i execute the main program and if it generates any errors i catch them. Now my problem is in the catch statement, i have this piece of code:
BEGIN TRY
INSERT INTO ContentTypes (ContentName, ContentPath) VALUES (@ContentName, @ContentPath)
SET @QResult = 0
END TRY
BEGIN CATCH
SET @QResult = 1
INSERT INTO Errors (ErrorNumber, ErrorLine, ErrorProcedure, ErrorSeverity, ErrorState, ErrorParameters)
VALUES (ERROR_NUMBER(), ERROR_LINE(), ERROR_PROCEDURE(), ERROR_SEVERITY(), ERROR_STATE(), 'ContentName:' + @ContentName + ',ContentPath:' + @ContentPath)
RETURN
END CATCH
This works perfectly until ContentName is NULL then it crashes, i forgot that you need to cast the values to string before you can add them to a nvarchar column. So how do i convert @ContentName before i insert it into the Errors table?