SHARE
TWEET

Untitled

a guest Jul 17th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE PROCEDURE dbo.[mainsproc]
  2.   WITH EXECUTE AS 'dynamicdatauser'
  3. AS
  4. BEGIN
  5.   DECLARE @SPROCNAME NVARCHAR(1000) = N'dbo.[optionalsproc]'
  6.   IF OBJECT_ID(@SPROCNAME,N'P') IS NOT NULL THEN
  7.   BEGIN
  8.     DECLARE @DYNSQL NVARCHAR(100) = N'EXEC ' + @SPROCNAME
  9.     EXEC sp_executeSQL @DYNSQL
  10.   END
  11. END
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top