ap_print_excec_cmd_sp

This is an private procedure that accepts an SQL string as parameter, and which prints and/or executes the statement, depending on the contents in the @printexec parameter. If the parameter includes a P, the statement is printed, if it includes an E, the statement is executed. Legal values are P, E, EP and PE.

 

Optionally the caller can specify a database name to run the statement in. This will result in two USE statements in the generated script in report mode.

 

The procedure saves commands to abarepltoagcmds if the @nosave parameter is 0 and

any of these is true: 1) @dbname is master 2) the batch includes a call to master.sys.sp_executesql.

 

Parameters:

@sql nvarchar(MAX) -- The statement, nvarchar(4000) on SQL 2000.

@printexec char(2) -- See above.

@dbname sysname = NULL -- Execute the statement in this database.

@nosave bit = 0 -- Don't save to abarepltoagcmds.