Customer Service 1-800-221-5528

SQL Server Programming Book for College Instructors | Murach Books

Murach’s SQL Server 2016 for Developers

by Bryan Syverson and Joel Murach
20 chapters, 676 pages, 291 illustrations
Published June 2016
ISBN 978-1-890774-96-7
List price: $57.50

As its title implies, this book presents all of the SQL Server 2016 skills that application developers need on the job (for the most recent edition, see our SQL Server 2019 edition). As such, it’s a great book for a SQL course. It can also add real-world perspective when it’s used as a supplementary text in any database course.

Latest Edition

Murach's SQL Server 2019 for Developers

Published April 2020

I was concerned about changing texts, but the student feedback on your SQL Server text has been amazing. I have had students buy this text who had previously not bought a text since first year."

Professor/Program Coordinator, Ontario

  • About this Book
  • Table of Contents
  • Courseware
  • FAQs
  • Corrections

What this book does

Section 1: An introduction to SQL

This section presents the concepts and terms for working with any database. Then, it shows how to use Microsoft SQL Server 2016 and the Management Studio to run SQL statements on a PC.

Section 2: The essential SQL skills

This section presents all the skills for retrieving data from a database and for adding, updating, and deleting that data. These skills move from the simple to the complex, and they include skills like using outer joins, summary queries, and subqueries.

Section 3: Database design and implementation

This section shows how to design a database and how to implement that design by using either SQL statements or the Management Studio. When your students are done, they’ll be able to design and implement their own databases.

Section 4: Advanced SQL skills

This section presents database features like views, scripts, stored procedures, functions, triggers, cursors, and transactions. It also shows how to manage database security and how to use the features for working with XML and BLOB data. These features illustrate the power of a database management system. Then, this section ends with an introduction to CLR integration, a feature that allows developers to create database objects using the C# or Visual Basic language.

Book features

Like all our books, this one has all of the Murach features that help your students learn faster and better. But here are a couple of features that are unique to this book.

It shows how to use a database before how to create one

Unlike most SQL books, this one starts by showing how to query an existing database rather than showing how to create a new database. Why?

For one thing, it’s motivating to see results right away, and querying provides that for your students; database design requires more study and background before you see results. But querying also helps to provide that kind of background, giving your students insight into the kind of decisions that have to be made in the design phase and the effects they have down the road.

As a result, doing querying first makes it easier for students to learn how to design and implement a database in section 3. And it also prepares them for using database features like views and stored procedures in section 4.

Real-world examples range from the simple to the complex

Like all our books, this one includes hundreds of examples. In this case, though, the examples are SQL statements that range from the simple to the complex. That way, your students can quickly get the idea of how a SQL feature works from the simple examples, but they’ll also see examples that illustrate real-world complexity...a feature that’s often missing in other SQL books.

What courses this book can be used for

  • This book and its instructional materials are widely used for SQL courses.
  • This book is also an excellent supplementary text for a more traditional database course.

What software your students need

Operating system

  • Windows 8 or later

SQL Server 2016 won’t install on Windows 7 or earlier. So your students need to have a later operating system to practice with the book examples or to do the chapter exercises on their personal systems.

For all chapters

To work with SQL Server as shown in this book, your students can download all the software they need from Microsoft’s website for free. That includes:

  • SQL Server 2016 Express
  • Express Edition of the SQL Server Management Studio

In appendix A in the book, your students will find complete instructions for installing these items on their PCs. And in chapter 2, they’ll learn how to use them.

For chapter 19

To work with the application code shown in chapter 19, on BLOBs, your students can use an Express Edition of Visual C# or Visual Basic. These products are also available from Microsoft’s website for free.

Presentation options

Because sections 3 and 4 are written as independent modules, you don’t have to teach all four sections of this book in sequence. For example, you can teach some or all of the advanced SQL skills of section 4 before you teach section 3 on database design and implementation.

Similarly, because the chapters in section 4 are modular, you don’t have to teach them in sequence and you don’t have to teach them all. When in doubt, of course, we think the book sequence is a good one. But if you’re short on time, you can skip some of these chapters.

What people say about this book

"Gave your SQL Server text a strong recommendation at Microsoft. I required their MTA certification as the final exam in the SQL course in the Fall. 15 of 17 passed."
- Keith E. Kelly, CIT Development Program Coordinator, Northwestern Michigan College

"I was concerned about changing texts, but the student feedback on your SQL Server text has been amazing. I have had students buy this text who had previously not bought a text since first year."
- Professor/Program Coordinator, Ontario

"By far the best introductory text I have come across for SQL Server, and I have reviewed and used many."
- Daniel A. Joseph, MIS Professor & Consultant, Rochester Institute of Technology

"The most positive feature of the book is the simple informative writing. Wow! I think a lot of thought went into this book before they ever wrote a word."
- Michael Robbins, Denver Visual Studio .NET Users Group

"From an academic perspective, I believe instructors will find this text comprehensive and easy-to-use. The student does not receive assignments that are abstract and pie-in-the-sky, but rather they develop projects comparable to real-life development activity."
- Eric Nothiesen, Enterprise Developers Guild

"The Perfect Book for Application Programmers: If you’re new to using SQL Server in your applications, this book will save you a lot of time. It teaches you about SQL, database design, a lot about admin (which many developers have to do; not everywhere has dedicated DBAs), and even provides C#/Visual Basic.NET example code. The advanced SQL is excellent. Highly recommended."
- David Bolton, Software Developer/Technical Writer and Reviewer

"Although I have used SQL Server on a daily basis for over 15 years, I was amazed at the number of new things that I learned while reading this book. I used a couple of the ideas to create a noticeable improvement in response time for one of my client/server projects."
- Brian Mishler, Orlando .NET User Group

"This book exceeds my expectations for books that teach database and software development. A wonderful book for both learning and mastering SQL Server."
- David Haertzen; posted at Infogoal.com

View the table of contents for this book in a PDF: Table of Contents (PDF)

Click on any chapter title to display or hide its content.

Section 1 An introduction to SQL

Chapter 1 An introduction to relational databases and SQL

An introduction to client/server systems

The hardware components of a client/server system

The software components of a client/server system

Other client/server system architectures

An introduction to the relational database model

How a database table is organized

How the tables in a relational database are related

How the columns in a table are defined

How relational databases compare to other data models

An introduction to SQL and SQL-based systems

A brief history of SQL

A comparison of Oracle, DB2, MySQL, and SQL Server

The Transact-SQL statements

An introduction to the SQL statements

Typical statements for working with database objects

How to query a single table

How to join data from two or more tables

How to add, update, and delete data in a table

SQL coding guidelines

How to work with other database objects

How to work with views

How to work with stored procedures, triggers, and user-defined functions

How to use SQL from an application program

Common data access models

How to use ADO.NET from a .NET application

Visual Basic code that retrieves data from a SQL Server database

C# code that retrieves data from a SQL Server database

Chapter 2 How to use the Management Studio

An introduction to SQL Server 2016

A summary of the SQL Server 2016 tools

How to start and stop the database engine

How to enable remote connections

An introduction to the Management Studio

How to connect to a database server

How to navigate through the database objects

How to manage the database files

How to attach a database

How to detach a database

How to back up a database

How to restore a database

How to set the compatibility level for a database

How to view and modify the database

How to view the database diagrams

How to view the column definitions of a table

How to modify the column definitions

How to view the data of a table

How to modify the data of a table

How to work with queries

How to enter and execute a query

How to handle syntax errors

How to open and save queries

An introduction to the Query Designer

How to view the documentation for SQL Server

How to display the MSDN website

How to look up information on the MSDN website

Section 2 The essential SQL skills

Chapter 3 How to retrieve data from a single table

An introduction to the SELECT statement

The basic syntax of the SELECT statement

SELECT statement examples

How to code the SELECT clause

How to code column specifications

How to name the columns in a result set

How to code string expressions

How to code arithmetic expressions

How to use functions

How to use the DISTINCT keyword to eliminate duplicate rows

How to use the TOP clause to return a subset of selected rows

How to code the WHERE clause

How to use comparison operators

How to use the AND, OR, and NOT logical operators

How to use the IN operator

How to use the BETWEEN operator

How to use the LIKE operator

How to use the IS NULL clause

How to code the ORDER BY clause

How to sort a result set by a column name

How to sort a result set by an alias, an expression, or a column number

How to retrieve a range of selected rows

Chapter 4 How to retrieve data from two or more tables

How to work with inner joins

How to code an inner join

When and how to use correlation names

How to work with tables from different databases

How to use compound join conditions

How to use a self-join

Inner joins that join more than two tables

How to use the implicit inner join syntax

How to work with outer joins

How to code an outer join

Outer join examples

Outer joins that join more than two tables

Other skills for working with joins

How to combine inner and outer joins

How to use cross joins

How to work with unions

The syntax of a union

Unions that combine data from different tables

Unions that combine data from the same table

How to use the EXCEPT and INTERSECT operators

Chapter 5 How to code summary queries

How to work with aggregate functions

How to code aggregate functions

Queries that use aggregate functions

How to group and summarize data

How to code the GROUP BY and HAVING clauses

Queries that use the GROUP BY and HAVING clauses

How the HAVING clause compares to the WHERE clause

How to code complex search conditions

How to summarize data using SQL Server extensions

How to use the ROLLUP operator

How to use the CUBE operator

How to use the GROUPING SETS operator

How to use the OVER clause

Chapter 6 How to code subqueries

An introduction to subqueries

How to use subqueries

How subqueries compare to joins

How to code subqueries in search conditions

How to use subqueries with the IN operator

How to compare the result of a subquery with an expression

How to use the ALL keyword

How to use the ANY and SOME keywords

How to code correlated subqueries

How to use the EXISTS operator

Other ways to use subqueries

How to code subqueries in the FROM clause

How to code subqueries in the SELECT clause

Guidelines for working with complex queries

A complex query that uses subqueries

A procedure for building complex queries

How to work with common table expressions

How to code a CTE

How to code a recursive CTE

Chapter 7  How to insert, update, and delete data

How to create test tables

How to use the SELECT INTO statement

How to use a copy of the database

How to insert new rows

How to insert a single row

How to insert multiple rows

How to insert default values and null values

How to insert rows selected from another table

How to modify existing rows

How to perform a basic update operation

How to use subqueries in an update operation

How to use joins in an update operation

How to delete existing rows

How to perform a basic delete operation

How to use subqueries and joins in a delete operation

How to merge rows

How to perform a basic merge operation

How to code more complex merge operations

Chapter 8  How to work with data types

A review of the SQL data types

Data type overview

The numeric data types

The string data types

The date/time data types

The large value data types

How to convert data

How data conversion works

How to convert data using the CAST function

How to convert data using the CONVERT function

How to use the TRY_CONVERT function

How to use other data conversion functions

Chapter 9 How to work with functions

How to work with string data

A summary of the string functions

How to solve common problems that occur with string data

How to work with numeric data

A summary of the numeric functions

How to solve common problems that occur with numeric data

How to work with date/time data

A summary of the date/time functions

How to parse dates and times

How to perform operations on dates and times

How to perform a date search

How to perform a time search

Other functions you should know about

How to use the CASE function

How to use the IIF and CHOOSE functions

How to use the COALESCE and ISNULL functions

How to use the GROUPING function

How to use the ranking functions

How to use the analytic functions

Section 3 Database design and implementation

Chapter 10 How to design a database

How to design a data structure

The basic steps for designing a data structure

How to identify the data elements

How to subdivide the data elements

How to identify the tables and assign columns

How to identify the primary and foreign keys

How to enforce the relationships between tables

How normalization works

How to identify the columns to be indexed

How to normalize a data structure

The seven normal forms

How to apply the first normal form

How to apply the second normal form

How to apply the third normal form

When and how to denormalize a data structure

Chapter 11 How to create a database and its tables with SQL Statements

An introduction to DDL

The SQL statements for data definition

Rules for coding object names

How to create databases, tables, and indexes

How to create a database

How to create a table

How to create an index

How to use snippets to create database objects

How to use constraints

An introduction to constraints

How to use check constraints

How to use foreign key constraints

How to change databases and tables

How to delete an index, table, or database

How to alter a table

How to work with sequences

How to create a sequence

How to use a sequence

How to delete a sequence

How to alter a sequence

The script used to create the AP database

How the script works

How the DDL statements work

Chapter 12 How to create a database and its tables with the Management Studio

How to work with a database

How to create a database

How to delete a database

How to work with tables

How to create, modify, or delete a table

How to work with foreign key relationships

How to work with indexes and keys

How to work with check constraints

How to examine table dependencies

How to generate scripts

How to generate scripts for databases and tables

How to generate a change script when you modify a table

Section 4 Advanced SQL skills

Chapter 13 How to work with views

An introduction to views

How views work

Benefits of using views

How to create and manage views

How to create a view

Examples that create views

How to create an updatable view

How to delete or modify a view

How to use views

How to update rows through a view

How to insert rows through a view

How to delete rows through a view

How to use the catalog views

How to use the View Designer

How to create or modify a view

How to delete a view

Chapter 14 How to code scripts

An introduction to scripts

How to work with scripts

The Transact-SQL statements for script processing

How to work with variables and temporary tables

How to work with scalar variables

How to work with table variables

How to work with temporary tables

A comparison of the five types of Transact-SQL table objects

How to control the execution of a script

How to perform conditional processing

How to test for the existence of a database object

How to perform repetitive processing

How to use a cursor

How to handle errors

How to use surround-with snippets

Advanced scripting techniques

How to use the system functions

How to change the session settings

How to use dynamic SQL

A script that summarizes the structure of a database

How to use the SQLCMD utility

Chapter 15 How to code stored procedures, functions, and triggers

Procedural programming options in Transact-SQL

Scripts

Stored procedures, user-defined functions, and triggers

How to code stored procedures

An introduction to stored procedures

How to create a stored procedure

How to declare and work with parameters

How to call procedures with parameters

How to work with return values

How to validate data and raise errors

A stored procedure that manages insert operations

How to pass a table as a parameter

How to delete or change a stored procedure

How to work with system stored procedures

How to code user-defined functions

An introduction to user-defined functions

How to create a scalar-valued function

How to create a simple table-valued function

How to create a multi-statement table-valued function

How to delete or change a function

How to code triggers

How to create a trigger

How to use AFTER triggers

How to use INSTEAD OF triggers

How to use triggers to enforce data consistency

How to use triggers to work with DDL statements

How to delete or change a trigger

Chapter 16 How to manage transactions and locking

How to work with transactions

How transactions maintain data integrity

SQL statements for handling transactions

How to work with nested transactions

How to work with save points

An introduction to concurrency and locking

How concurrency and locking are related

The four concurrency problems that locks can prevent

How to set the transaction isolation level

How SQL Server manages locking

Lockable resources and lock escalation

Lock modes and lock promotion

Lock mode compatibility

How to prevent deadlocks

Two transactions that deadlock

Coding techniques that prevent deadlocks

Chapter 17 How to manage database security

How to work with SQL Server login IDs

An introduction to SQL Server security

How to change the authentication mode

How to create login IDs

How to delete or change login IDs or passwords

How to work with database users

How to work with schemas

How to work with permissions

How to grant or revoke object permissions

The SQL Server object permissions

How to grant or revoke schema permissions

How to grant or revoke database permissions

How to grant or revoke server permissions

How to work with roles

How to work with the fixed server roles

How to work with user-defined server roles

How to display information about server roles and role members

How to work with the fixed database roles

How to work with user-defined database roles

How to display information about database roles and role members

How to deny permissions granted by role membership

How to work with application roles

How to manage security using the Management Studio

How to work with login IDs

How to work with the server roles for a login ID

How to assign database access and roles by login ID

How to assign user permissions to database objects

How to work with database permissions

Chapter 18 How to work with XML

An introduction to XML

An XML document

An XML schema

How to work with the xml data type

How to store data in the xml data type

How to work with the XML Editor

How to use the methods of the xml data type

An example that parses the xml data type

Another example that parses the xml data type

How to work with XML schemas

How to add an XML schema to a database

How to use an XML schema to validate the xml data type

How to view an XML schema

How to drop an XML schema

Two more skills for working with XML

How to use the FOR XML clause of the SELECT statement

How to use the OPENXML statement

Chapter 19 How to work with BLOBs

An introduction to BLOBs

Pros and cons of storing BLOBs in files

Pros and cons of storing BLOBs in a column

When to use FILESTREAM storage for BLOBs

How to use SQL to work with a varbinary(max) column

How to create a table with a varbinary(max) column

How to insert, update, and delete binary data

How to retrieve binary data

A .NET application that uses a varbinary(max) column

The user interface for the application

The event handlers for the form

A data access class that reads and writes binary data

How to use FILESTREAM storage

How to enable FILESTREAM storage on the server

How to create a database with FILESTREAM storage

How to create a table with a FILESTREAM column

How to insert, update, and delete FILESTREAM data

How to retrieve FILESTREAM data

A data access class that uses FILESTREAM storage

Chapter 20 An introduction to CLR integration

An introduction to CLR integration

How CLR integration works

The five types of CLR objects

When to use CLR objects

How to enable CLR integration

How to use SQL to work with CLR objects

How to deploy an assembly

How to deploy a CLR object

How to drop an assembly

Appendix A How to set up your computer for this book

The five editions of SQL Server 2016 Express

How to install SQL Server 2016 Express with Tools

How to install the files for this book

How to create the databases for this book

How to restore the databases for this book

How to install Visual Studio Express

If you aren’t already familiar with the supporting courseware that we provide for a book, please go to About our Courseware. As you will see, our courseware consists of the end-of-chapter activities in the book, the files in the student download at our retail site, and the instructor’s materials. These components provide everything that other publishers provide in a way that delivers better results.

If you are familiar with our courseware, here’s a quick summary of the courseware for this book. For a detailed description in PDF format, please read the Instructor’s Summary.

End-of-chapter activities in the book

  • Term lists
  • Practice exercises

Student download at our retail site

  • Script files that create the databases used by the examples and exercises in this book
  • Scripts for all of the examples in the book
  • C# and Visual Basic projects for the application presented in chapter 19
  • Solutions to the book exercises

Appendix A in the book gives your students complete instructions for downloading and installing these items on their PCs.

Instructor’s materials

  • Instructional objectives by chapter
  • PowerPoint slides for classroom presentations
  • Test banks in multiple formats
  • A second full set of chapter-by-chapter exercises that aren’t in the book, plus their solutions
  • The files that students can download at our retail site (see above)

Below are the answers to the questions that have come up most often about this book. If you have a question that isn’t answered here, please email us. Thanks!

Why won’t SQL Server 2016 Express install on my Windows 7 computer?

SQL Server 2016 Express requires Windows 8 or later as the operating system.

Why do I get an error about a version mismatch when I try to attach the databases for this book?

This error occurs when you have an older version of SQL Server (besides the 2016 version) installed on your system. Often, you aren’t even aware that this older version is on your system because the software was installed as part of another product, such as Visual Studio.

To solve this problem, you can use the SQL Server Configuration Manager to view the instances of SQL Server that are running on your computer. This lets you view their names. Then, you can use the SQL Server Management Studio to connect to the correct instance. After you connect, you can make sure you are connected to the correct version by viewing the version number of the server in the Object Explorer window.

Here’s how the version numbers correspond to the product names:

  • Version 10.x→SQL Server 2008
  • Version 11.x→SQL Server 2012
  • Version 12.x→SQL Server 2014
  • Version 13.x→SQL Server 2016

There are no book corrections that we know of at this time. But if you find any, please email us, and we’ll post any corrections that affect the technical accuracy of the book here. Thank you!

Murach college books and courseware since 1974