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 11: Writing Scripts and Batches<br />

Exercises<br />

1. Write a simple script that creates two integer variables (one called Var1 and one called Var2),<br />

places the values 2 and 4 in them respectively, and then outputs the value of the two variables<br />

added together.<br />

2. Create a variable called MinOrder and populate it with the smallest line item amount after discount<br />

for AdventureWorks<strong>2008</strong> CustomerID 1 (Careful: we’re dealing with currency here, so<br />

don’t just assume you’re going to use an int.) Output the final value of MinOrder.<br />

3. Use sqlcmd to output the results of the query SELECT COUNT(*) FROM Customers to the console<br />

window.<br />

365

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

Saved successfully!

Ooh no, something went wrong!