Learn more about Toad for SQL Server
at Dell Software

Find solutions and downloads at the
Toad for SQL Server Support Portal

Toad for SQL Server 6.6

You are here: Edit SQL > Reuse SQL > Record and Play Macros

Record and Play Macros

Use Macros to record a series of keyboard commands in the Editor that can be played back multiple times. This is useful for reducing the amount of manual typing you have to do.

Scenario

You have an INSERT statement with 500 lines of data to insert in the Directors table of the MOVIES database. Before executing the script, a new policy is created to change the order of two columns from LastName, FirstName to FirstName, LastName. Using Macros, you can record the keystroke actions to switch the order of the data values to FirstName and LastName for the first line; and can then press CTRL+SHIFT+P to play the macro and switch the order for the remaining 499 lines.

To create a macro for this example

  1. Place the cursor at the beginning of the first row.

  2. Press CTRL+SHIFT+R to begin recording the macro.

  3. Press CTRL+SHIFT+RIGHT to select the value for LastName in the first row.

  4. Press CTRL+X to remove the LastName.

  5. Press DELETE to remove the comma.

  6. Press END to move to the end of the line.

  7. Press ”,” to add a comma.

  8. Press CTRL+V to paste the LastName after the FirstName.

  9. Press HOME to return to the start of the line.

  10. Press DOWN to move to the next line.

  11. Press CTRL+SHIFT+R to stop recording.

  12. Press CTRL+SHIFT+P to play the macro.

 

Related Topics

of