Incorrect syntax near 'THROW'

前端 未结 3 760
一生所求
一生所求 2020-12-17 07:56
IF @SQL IS NOT NULL
BEGIN
    BEGIN TRY 
        EXEC sp_executesql @SQL
        PRINT \'SUCCESS: \' + @SQL
    END TRY 
    BEGIN CATCH
        SET @ErrorMessage =          


        
3条回答
  •  时光取名叫无心
    2020-12-17 08:43

    I just hit the same error but for a completely different reason. The machine I'm using is slightly old but has SSMS 2012 (the version that THROW was introduced). However the actual SQL server is 10.5 (which is 2008 R2; see https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-transact-sql-compatibility-level) and so the command is not valid.

    Hopefully there won't be too many instances of ten year old setups out there but double check if you get this and you're sure your syntax is correct!

提交回复
热议问题