This procedure allows you to generate an insert statement for a table, based on a particular row in that table. We made this procedure flexible: you can enter in the name of any Minion table, and a row ID, and it will generate the insert statement for you.

Note that this function is shared between Minion modules.

WARNING: This generates a clone of an existing row as an INSERT statement. Before you run that insert, be sure to change key identifying information - e.g., the DBName - before you run the INSERT statement; you would not want to insert a completely identical row.

 

Name Type Description
@TableName Varchar

The name of the table to generate an insert statement for.

 

Note: This can be in the format "Minion.CheckDBSettingsDB" or just " CheckDBSettingsDB".

@ID Int

The ID number of the row you'd like to clone. See the discussion below.

@WithTrans Bit

Include “BEGIN TRANSACTION” and “ROLLBACK TRANSACTION” clauses around the insert statement, for safety.

Discussion

Because of the way we have writte Minion CheckDB, you may often need to insert a row that is nearly identical to an existing row. If you want to change just one setting, you still have to fill out 40 columns. For example, you may wish to insert a row to Minion.CheckDBSettingsDB that is only different from the MinionDefault rows in two respects (e.g., DBName and GroupOrder).

We created Minion.CloneSettings to easily duplicate any existing row in any table. This "helper" procedure lets you pass in the name off the table you would like to insert to, and the ID of the row you want to model the new row off of. The procedure returns an insert statement so you can change the one or two values you want.

Discussion: Identity columns

If the table in question has an IDENTITY column, regardless of that column’s name, Minion.CloneSettings will be able to use it to select your chosen row. For example, let’s say that the IDENTITY column of Table1 is ObjectID, and that you call Minion.CloneSettings with @ID = 2. The procedure will identify that column and return an INSERT statement that contains the values from the row where ObjectID = 2.