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.

Chapter 12: Stored Procedures<br />

matches with the current statement shown in Figure 12-3) probably isn’t all that new of a concept to you.<br />

Simply put it shows you the current value of all the variables that are currently in scope. The list of variables<br />

in the Locals window may change (as may their values) as you step into nested sprocs and back<br />

out again. Remember — these are only those variables that are in scope as of the next statement to run.<br />

In Figure 12-4, we’re at the start of our first run through this sproc, so the value for the @ValueIn parameter<br />

has been set, but all other variables and parameters are not yet set and thus are effectively null.<br />

Figure 12-4<br />

Three pieces of information are provided for each variable or parameter:<br />

❑ The name<br />

❑ The current value<br />

❑ The data type<br />

However, perhaps the best part to the Locals window is that you can edit the values in each variable.<br />

That means it’s a lot easier to change things on the fly to test certain behaviors in your sproc.<br />

The Watch Window<br />

404<br />

Here you can set up variables that you want to keep track of regardless of where you currently are in the<br />

call stack. You can either manually type in the name of the variable you want to watch, or you can select<br />

that variable in code, right click, and then select Add Watch. In Figure 12-5, I’ve added a watch for<br />

@ValueOut, but, since we haven’t addressed that variable in code, you can see that no value has been set<br />

for it as yet.<br />

Figure 12-5

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

Saved successfully!

Ooh no, something went wrong!