troubleshooting Question

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

Avatar of Scott Townsend
Scott TownsendFlag for United States of America asked on
Microsoft SQL ServerMicrosoft SQL Server 2008SQL
15 Comments1 Solution166 ViewsLast Modified:
I Need to alter an extended stored procedure in SQL 2008R2.  Pretty much exactly like here: 
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.

Scott Townsend
IT Director

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros