Code View Window
Generating scripts from schema differences.
When
in the Schema Viewer you select one or more of the highlighted schema items and use on
them either of the "Show changes to ..." commands (Ctrl-Alt-LEFT | RIGHT),
AdeptSQL Diff generates a difference script for the selected items and shows it in
the "SQL Code View" popup window (shown below), ready to be sent to the
server.Although the Code View window is not a
full-featured SQL debugger (it can't step inside a stored procedure or
display SQL variables), it does provide some convenient script execution commands you'd expect to see in one. |
Choosing a target.
The result of using the
code window may be applied to either of the databases taking part in the
comparison. You can choose the database in the "Target" combo box. Of course,
usually it only makes sense to apply it to the database the script has been
generated for, which is the initial choice in that combo box.
If you open a script file in this window, there would be no default
target, so you must choose one before you can do anything with that script.
Executing the script
With
the following buttons you can control execution of a difference script:
|
Img |
Keys
(depending on key mapping) |
Menu |
Description |
|

|
F9 |
"Run" |
Run the whole script from the beginning or from the current execution point ( ). |
 |
Ctrl-Shift-F8 |
"Skip" |
Skip to the next SQL statement without executing this one. May be convenient
when there is an error in the SQL which you don't care to fix right now. |
 |
F8 |
"Step" |
Execute the current SQL statement. If there is no execution point yet, the
command just sets the EP to the first statement - you have to "step" again to
get that statement executed. |
 |
|
"Stop" |
Enabled only while the script is being executed (by the "Run" command). Makes
the execution stop after finishing the current statement. It does not break the
connection immediately, so if the server is doing some bulky query you may be
stuck till it's done. |
Executing a selection. If you select part of the SQL, the Run
command will only execute this selected part and then reset the selection.
Execution of selected SQL text does not interfere with the current execution
point. E.g. you can step-through to some SQL, then select and execute a piece
of code elsewhere in the script, then resume execution where it stopped.
The transaction control. The program remembers the position in the
script where the transaction has started and returns the execution pointer
there if the transaction gets rolled back due to an error. When a SQL statement such as
{BEGIN | COMMIT | ROLLBACK} TRAN[SACTION] is executed, the program recognizes
that and updates its state automatically.
You can also enter or leave a transaction manually, using the
(Start),
(Commit) or
(Rollback) buttons on
the Code Viewer's toolbar:
|
Img |
Menu |
Description |
|

|
"Transaction/Start" |
Enters a transaction. The program passes BEGIN TRANS to the server and
remembers the current execution point, so it can return there if the transaction
fails. |
 |
"Transaction/Commit" |
Successfully finish the transaction. Passes COMMIT TRANS to the server and
discards the stored return position. |
 |
"Transaction/Rollback" |
Passes ROLLBACK to the server and returns to the stored position in the script,
so you can correct the errors and retry. |
Note: named transactions and
checkpoints are not supported. When the SQL parser sees one of those, it
simply ignores any additional parameters. The command goes to the SQL
server exactly as it is, but the program remains unaware of the transaction
name. If you now try to press
(Rollback), the program
will issue a regular unnamed "ROLLBACK TRANS" and that will
cause error on the server. This limitation should not present a problem, as we are dealing here
with straightforward difference scripts where you can hardly expected any named transactions.
The gutter bar menu.
In the gutter area of the editor, the first line of each SQL statement is
marked with a tiny dot ( ). When you
click on the dot, a menu pops up - see the snapshot. Here you can select
the whole statement, toggle breakpoint or specify the statement the execution
will be resumed at.
The same commands are available from the right-click menu of the code editor
itself - the commands will be applied to the SQL statement the caret is
(or the selection starts) within. In other words, if you place the caret
anywhere between the beginning of the statement and the terminating "GO" then
press F5, the breakpoint will appear at the beginning of the statement.
|