The interface to the application of dynamic SQL templates and code generation  consists of 2 procedures


Reads the source code of a template, replaces the parameters with the given values and executes the generated SQL code.

@DSQLTProc sysname = null
, @p1 NVARCHAR (MAX) = null
, @p2…@p8 NVARCHAR (MAX) = null
, @p9 NVARCHAR (MAX) = null
, @Database sysname = null
, @Template NVARCHAR (MAX) = null OUTPUT
, @Create sysname = null
, @Print bit = 0

@DSQLTProc: the name of the template. This must be the name of a stored procedure defined in any schema in the current database. The name must start with @ sign. Use null, if you want to use as a template a string instead of a procedure. Then the contents of @template are used instead of a stored procedure.
@p1-@p9: This are the contents for the parameter substitution, corresponding to @1 - @9. Use null to suppress replacement.
@Database: The database, the generated SQL code should be executed within. null results in the execution in the current database.
This name is also under parameter substitution, if it contains the parameter @0 - @9t.

@Template: This can be passed instead of a string template procedure. Also serves as an optional output parameter to return the generated SQL code.
@Create: The name to generate a stored procedure with includes the generated code. If a same procedure already exists, it will be replaced.
This name is also under parameter substitution, if it contains the parameter @0 - @9.

@Print: controls whether the generated code is executed (0) or printed (1). null results in neither happening, but instead returning the generated code in the OUTPUT Parameter @template.




Last edited Jan 20, 2011 at 10:27 PM by HenrikBauer, version 1


No comments yet.