T-SQL Throw Exception
I am facing the famous 'Incorrect syntax' while using a THROW statement in a T-SQL stored procedure. I have Googled it and checked the questions on StackOverflow but the solutions proposed (and strangely, accepted) do not work for me. I am modifying a stored procedure as follows: ALTER PROCEDURE [dbo].[CONVERT_Q_TO_O] @Q_ID int = NULL, @IDENTITY INT = NULL OUTPUT AS BEGIN SET NOCOUNT ON; DECLARE @EXISTING_RECORD_COUNT [int]; SELECT @EXISTING_RECORD_COUNT = COUNT (*) FROM [dbo].[O] WHERE [Q_ID] = @Q_ID IF @EXISTING_RECORD_COUNT = 0 BEGIN -- DO SOME STUFF HERE -- RETURN NEW ID SELECT @IDENTITY =