Replace EXEC @SQL with EXEC (@SQL)
Without the brackets, the assumption is that the content of the variable is a stored procedure name
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability