17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

❑ There are icons at the top (see Figure 12-3) to indicate our different options, including:<br />

❑ Continue: This will run to the end of the sproc or the next breakpoint (including a<br />

watch condition).<br />

❑ Step Into: This executes the next line of code and stops prior to running the following<br />

line of code, regardless of what procedure or function that code is in. If the line of code<br />

being executed is calling a sproc or function, then Step Into has the effect of calling that<br />

sproc or function, adding it to the call stack, changing the locals window to represent<br />

the newly nested sproc rather than the parent, and then stopping at the first line of code<br />

in the nested sproc.<br />

❑ Step Over: This executes every line of code required to take us to the next statement<br />

that is at the same level in the call stack. If you are not calling another sproc or a UDF,<br />

then this command will act just like a Step Into. If, however, you are calling another<br />

sproc or a UDF, then a Step Over will take you to the statement immediately following<br />

where that sproc or UDF returned its value.<br />

❑ Step Out: This executes every line of code up to the next line of code at the next highest<br />

point in the call stack. That is, we will keep running until we reach the same level as<br />

whatever code called the level we are currently at.<br />

❑ Stop Debugging: Again, this does what it says — it stops execution immediately. The<br />

debugging window does remain open, however.<br />

❑ Toggle Breakpoints and Remove All Breakpoints: In addition, you can set breakpoints<br />

by clicking in the left margin of the code window. Breakpoints are points that you set to<br />

tell <strong>SQL</strong> <strong>Server</strong> to “stop here!” when the code is running in debug mode. This is handy<br />

in big sprocs or functions where you don’t want to have to deal with every line — you<br />

just want it to run up to a point and stop every time it gets there.<br />

Figure 12-2<br />

Figure 12-3<br />

In addition, there is a choice that brings up the Breakpoints window, which is a list of all breakpoints<br />

that are currently set (again, handy in larger blocks of code). There are also a few of what we’ll call “status”<br />

windows; let’s go through a few of the more important of these.<br />

The Locals Window<br />

Chapter 12: Stored Procedures<br />

As I indicated back at the beginning of the book, I’m pretty much assuming that you have experience<br />

with some procedural language out there. As such, the Locals window (shown in Figure 12-4 as it<br />

403

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!