text: SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_NULLS ON
  GO
  CREATE PROCEDURE [tSQLt].[SpyProcedure]
      @ProcedureName NVARCHAR(MAX),
      @CommandToExecute NVARCHAR(MAX) = NULL
  AS
  BEGIN
      DECLARE @ProcedureObjectId INT;
      SELECT @ProcedureObjectId = OBJECT_ID(@ProcedureName);
  
      EXEC tSQLt.Private_ValidateProcedureCanBeUsedWithSpyProcedure @ProcedureName;
  
      DECLARE @LogTableName NVARCHAR(MAX);
      SELECT @LogTableName = QUOTENAME(OBJECT_SCHEMA_NAME(@ProcedureObjectId)) + '.' + QUOTENAME(OBJECT_NAME(@ProcedureObjectId)+'_SpyProcedureLog');
  
      EXEC tSQLt.Private_RenameObjectToUniqueNameUsingObjectId @ProcedureObjectId;
  
      EXEC tSQLt.Private_CreateProcedureSpy @ProcedureObjectId, @ProcedureName, @LogTableName, @CommandToExecute;
  
      RETURN 0;
  END;
  GO
  