Beginning T-SQL (3rd Edition)
[Link]
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Beginning T-SQL (3rd Edition)
Contents at a Glance
[Link]
About the Authors������������������������������������������������������������������������������������������������������������ xxiii
About the Technical Reviewer ������������������������������������������������������������������������������������������ xxv
Acknowledgments ��������������������������������������������������������������������������������������������������������� xxvii
Foreword ������������������������������������������������������������������������������������������������������������������������� xxix
■ Chapter 1: Getting Started �������������������������������������������������������������������������������������������������1
■ Chapter 2: Exploring Database Concepts ������������������������������������������������������������������������19
■ Chapter 3: Writing Simple SELECT Queries ����������������������������������������������������������������������31
■ Chapter 4: Using Built-In Functions and Expressions �����������������������������������������������������59
■ Chapter 5: Joining Tables ����������������������������������������������������������������������������������������������101
■ Chapter 6: Building on Subqueries, Common Table Expressions, and Unions ���������������127
■ Chapter 7: Grouping and Summarizing Data �����������������������������������������������������������������147
■ Chapter 8: Discovering Windowing Functions ���������������������������������������������������������������169
■ Chapter 9: Advanced WHERE Clauses ����������������������������������������������������������������������������193
■ Chapter 10: Manipulating Data ��������������������������������������������������������������������������������������211
■ Chapter 11: Writing Advanced Queries��������������������������������������������������������������������������241
■ Chapter 12: Understanding T-SQL Programming Logic �������������������������������������������������275
■ Chapter 13: Managing Transactions ������������������������������������������������������������������������������309
■ Chapter 14: Implementing Logic in the Database ��������������������������������������������������������325
This Book is Available on [Link]
v
■ Contents at a GlanCe
Beginning T-SQL (3rd Edition)
■ Chapter 15: Working with XML ��������������������������������������������������������������������������������������379
■ Chapter 16: Expanding on Data Type Concepts �������������������������������������������������������������403
■ Chapter 17: Running SQL Server in the Cloud ���������������������������������������������������������������433
■ Chapter 18: Where to Go Next?��������������������������������������������������������������������������������������449
[Link]
Index ���������������������������������������������������������������������������������������������������������������������������������453
This Book is Available on [Link]
vi
ChAPter 1 ■ GettinG StArted
Beginning T-SQL (3rd Edition)
Here are the steps to follow to install SQL Server Express:
1. Once you have downloaded the SQL Server 2014 Express with Advanced Services
installation file from Microsoft’s site, double-click the file to extract and start up the
SQL Server Installation Center. Figure 1-1 shows the Planning pane of the SQL Server
Installation Center once the extraction has completed. You may need to click Planning in
the left-hand side to see these options.
[Link]
Figure 1-1. SQL Server Installation Center’s Planning pane
2. To make sure your system meets all the requirements to install SQL Server Express with
Advanced Services, click the System Configuration Checker link, which opens the Global
Rules screen (Figure 1-2). Click Show details to see more information if the system does
not meet the requirements. Click OK to dismiss the screen when you are done or the
screen may close on its own if there are no issues.
This Book is Available on [Link]
2
ChAPter 1 ■ GettinG StArted
Beginning T-SQL (3rd Edition)
[Link]
Figure 1-2. The Global Rules details page
3. If your system doesn’t meet the requirements, click the Hardware and Software
Requirements link on the Planning pane of the SQL Server Installation Center, which will
take you to a web page on Microsoft’s web site. Be sure to scroll down the web page to find
the information for the Express edition. The hardware requirements are not difficult to
meet with today’s PCs.
4. Once you are certain that your computer meets all the requirements, switch to the
Installation pane, shown in Figure 1-3, and click New SQL Server stand-alone installation
or add features to an existing installation.
This Book is Available on [Link]
3
ChAPter 1 ■ GettinG StArted
Beginning T-SQL (3rd Edition)
[Link]
Figure 1-3. The Installation pane
5. Once the installation wizard starts up, read and accept the license terms. Click Next.
6. On the Microsoft Update screen, check if you wish to get automatic updates for SQL Server.
Click Next.
7. Several screens checking for product updates, installing setup files, and checking rules
will quickly display. If there are no problems, these screens will advance to the Feature
Selection screen shown in Figure 1-4. Be sure to select the Database Engine Services, Full
Text, the Documentation Components, and the Management Tools. Click Next.
This Book is Available on [Link]
4
ChAPter 1 ■ GettinG StArted
Beginning T-SQL (3rd Edition)
[Link]
Figure 1-4. Select the Installation Type
8. On the Instance Configuration screen (Figure 1-5), you can choose a Default instance
or a Named instance. When installing SQL Server Express edition, it will be named
SQLEXPRESS unless you change it. Write down what you decide to do on this screen
because you will need this information when connecting to SQL Server later. Click Next.
This Book is Available on [Link]
5
ChAPter 1 ■ GettinG StArted
Beginning T-SQL (3rd Edition)
[Link]
Figure 1-5. The Instance Configuration screen
■ Named Instances Multiple SQL Server installations can run on one computer. each installation is called an instance.
You may have only one default instance on a computer. Any additional instances must be named. When connecting to
named instances, use the computer name plus the instance name: computerName\instanceName.
9. On the Service Configuration screen, you must specify accounts under which SQL Server
will run. If you are setting up SQL Server for a production environment, you may want
to have a special service account to make sure that the installation is secure. Installing
a secure SQL Server instance is beyond the scope of this book. Because you are just
installing the Express edition for learning purposes here, choose the defaults for all the
services and click Next.
This Book is Available on [Link]
6