Avatar of Scott Townsend
Scott Townsend
Flag for United States of America

asked on 

override system extended stored procedure sp_executesql with my own code, but still call the original code if needed.

I Need to alter an extended stored procedure in SQL 2008R2.  Pretty much exactly like here: https://www.experts-exchange.com/questions/21081340/Microsoft-SQL-System-Extendend-Stored-Procedure-Overwrite-sp-executesql.html 
Though that ended up without a solution.

I need to use the same name as an Existing stored procedure though.

I want to be able to test for a parameter to the Stored procedure and Exit if it contains a keyword. If it does not, then I want to execute the original SP as usual.

So something like:

sys.sp_executesql  -> sp_origexecutesql

New sys.sp_executesql  
      if @P1 = "Select * from NoNoTable" return NULL
      Else exec sp_origexecutesql @P1

I have SysAdmin Access to the SQL Server, so I can make any changes there. I can Create my Own DLL Code if needed too. I just don't have access to all of the Code that is running against the SQL Server and I want to Intercept some of the sp_executesql Commands.

Microsoft SQL ServerMicrosoft SQL Server 2008SQL

Avatar of undefined
Last Comment
Scott Townsend

8/22/2022 - Mon