Code generator - exec any procedure 

 

Download sample code: WizExecProc.zip  

This is a simple stored procedure to generate a query for execution of any stored procedure.

Syntax:
     exec wiz_ExecProc 'procname'

For example, you have a procedure with the parameters:

CREATE PROCEDURE TestMe

    ( @number               int,

      @string               varchar(30),

      @date                 datetime,

 

      @ret_string           char(10)      OUT,

      @ret_number           decimal(18,3) OUT

) AS

  print 'Something'

GO

Then you type:
exec wiz_ExecProc 'TestMe'

and get the results:

   set dateformat dmy

   set nocount on

   set implicit_transactions on

   set concat_null_yields_null off

 

   declare @ret_string                     char(10)

   declare @ret_number                     decimal(18,3)

 

   exec TestMe

                @number                         = 0, -- int

                @string                         = '-', -- varchar(30)

                @date                           = '01 Oct 2007 13:29:10:560', -- datetime

                @ret_string                     = @ret_string OUT,

                @ret_number                     = @ret_number OUT

 

   select @ret_string '@ret_string', @ret_number '@ret_number'

 

You should only copy results from the bottom of the screen of QueryAnalyzer to the top and assign values.