Using Db Maint, Working with…
User Defined Commands
You can add your own commands to the Db Maint client. These are stored in a Db
Maint table in the msdb database. A command can be defined at the server,
database, table or index level. The server-, database-, table-, and index- name
will substitute a placeholder in the command string, which makes the commands
context-sensitive. You can also define up to 6 other placeholders for other
parameters. If any user-defined placeholder is defined then a dialog is shown when you
execute the command allowing you to specify a value for each parameter. Db
Maint ships with a number of pre-defined user-defined commands. You can
add/remove/edit these and of course add your own.
User-defined commands dialog
To open this dialog, right-click the level where you want to add/remove/edit
commands and select “User-defined commands”, “Modify”.
Menu caption
This is the name of the command as will be displayed when you right-click the
option and when in the pop-up menu select “User-defined commands”.
Command
This is the TSQL command(s) that will be sent to SQL Server. You can specify
several commands, they will be sent as one batch to SQL Server. To substitute
the object-name selected, you use <servername>, <databasename>, <tablename> and
<indexname>.
You can also use up to 6 other placeholders, for example:
<ParmName1: "Database Name">.
If you have any user-defined placeholders, a dialog will show when you execute
the command, allowing you to substitute the placeholder with a value. Below
are a couple of example of user-defined commands showing both context-sensitive
placeholders and user-defined placeholders:
DROP TABLE <tablename>
DBCC SHOW_STATISTICS ('<tablename>', '<indexname>')
EXEC sp_addsrvrolemember @loginame = '<ParmName1: "Login name">', @rolename =
'<ParmName2: "Server role name">'
Description
Type a description for the command, if you like. This is for your convenience.
Other options
Select the SQL Server version(s) that the command should be available for.
Select whether the command should be displayed or not. You might temporarily
want to hide a command without removing it, for example.
Select whether you want a confirmation dialog or not.
Replace command parameters dialog
If you have specified any user-defined placeholders for a command, this dialog
will be displayed.
Result, user-defined commands
This is displayed after executing a user-defined command.