Procedure executes provided SQL Code in the context of the target database.
In many cases user might have tables with the same names located in the different database that store similar database-specific data, but not the same data. This procedure allows you to ensure that SQL code is executed precisely in the expected contexts and avoid ambiguity.
- This procedure exists only in SQL Server versions of the DB Test Driven framework at this time.
v_TargetDatabase – the target database, SYSNAME
v_SQLCode – SQL Code that will be executed in the target database, NVARCHAR(MAX)
SET @v_SQL = 'INSERT INTO MyTable (MyColumn) SELECT Name AS MyColumn FROM OtherTable';
SET @v_Database = 'clientdb'
EXEC DBTD_SP_EXECUTESQL @v_Database, @v_SQL