CHAPTER 2
Elementary Programming
In this chapter, you’ll find recipes showing several of the basic programming constructs available in T-SQL. The chapter is not a complete tutorial for the language, however. You’ll need to read other books for that. A good tutorial, if you need one that begins with first principles, is Beginning T-SQL by Kathi Kellenberger and Scott Shaw (Apress, 2014).
2-1. Executing T-SQL from a File
Problem
You want to execute a script of T-SQL commands that you’ve stored in a file.
Solution
Invoke your script via the sqlcmd utility. For example, say that you create a file named CreateColorTable.sql having ...
Get SQL Server T-SQL Recipes, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.