Practical SQL Microsoft SQL Server T SQL for Beginners Mark O’Donovan instant download
Practical SQL Microsoft SQL Server T SQL for Beginners Mark O’Donovan instant download
https://ebookname.com/product/practical-sql-microsoft-sql-server-
t-sql-for-beginners-mark-odonovan/
https://ebookname.com/product/beginning-t-sql-with-microsoft-sql-
server-2005-and-2008-paul-turley/
https://ebookname.com/product/microsoft-sql-server-2008-for-
dummies-1st-edition-chapple/
https://ebookname.com/product/microsoft-sql-server-2012-with-
hadoop-1st-edition-debarchan-sarkar/
https://ebookname.com/product/strategies-for-successful-animal-
shelters-1st-edition-laura-a-reese-ph-d/
King Tiger vs IS 2 Operation Solstice 1945 Duel First
Edition David R. Higgins
https://ebookname.com/product/king-tiger-vs-is-2-operation-
solstice-1945-duel-first-edition-david-r-higgins/
https://ebookname.com/product/english-civil-war-brassey-s-
history-of-uniforms-1st-english-ed-edition-philipp-elliot-wright/
https://ebookname.com/product/the-method-of-the-divine-
government-physical-and-moral-2nd-edition-james-mccosh/
https://ebookname.com/product/social-movements-2nd-edition-
staggenborg/
https://ebookname.com/product/mobile-robots-towards-new-
applications-1st-edition-aleksandar-lazinica/
Practical Handbook of Photovoltaics Fundamentals and
Applications 1st Edition Augustin Mcevoy
https://ebookname.com/product/practical-handbook-of-
photovoltaics-fundamentals-and-applications-1st-edition-augustin-
mcevoy/
Practical Sql
Microsoft Sql Server T-SQL
for Beginners
2nd Edition
By
Mark O'Donovan
Copyright © 2019 Mark O’Donovan
All rights reserved.
Contents
Disclaimer
Although the author and publisher have made every effort to ensure that the
information in this book was correct at press time, the author and publisher do
not assume and hereby disclaim any liability to any party for any loss, damage,
or disruption caused by errors or omissions, whether such errors or omissions
result from negligence, accident, or any other cause.
Title: Practical Sql - Microsoft Sql Server T-SQL for Beginners – Second
Edition
Version: 2.0
Software and Sample Data
The examples in this book used Sql Server 2017 Express which is as of
writing this book a free version of sql server available for download from
Microsoft.
You can download all the sample data and examples for this book from
https://github.com/techstuffy/Practical-Sq
Most examples will run on previous versions of Microsoft Sql Server but
some functions might differ or not exist on previous versions such as the format
function.
If you have problems accessing the sample data please contact me using
techstuffy.com.
Overview
A brief overview of the different sections contained within this book :
Chapter 1
This chapter introduces the book , how to use the book and where to get
downloads.
Chapter 2
Here we cover how to get a free copy of sql server express and the
installation of the software.
Chapter 3
Once sql server has been installed this chapter will take you on a brief tour of
the software and how to login to the sql server for the first time.
Chapter 1
This chapter will show you how to create your first sql server database and
the various properties of sql server databases.
Chapter 2
Once you have created your database this chapter will explain and give
examples of creating sql server tables to store your data.
Chapter 3
In the final chapter of this section with introduce the basic sql statements to
insert, query, update and delete data from a sql table.
Section 3. Advanced Queries
Section 3 goes into sql development in more detail cover ways of grouping
data, creating conditional statements and joining tables of data together.
Chapter 1
Chapter 2
Chapter 3
Chapter 4
When developing sql databases more often than not the data you need to
return will be in more than one table. This chapter covers the various ways you
can combine the data in 2 or more tables.
Section 4. Sql Beyond the Basics
Now that the basics of sql development have been covered Section 4 carries
on by introducing more development techniques such as using Stored
Procedures, Functions and Views, Triggers, database design rules and much
more.
Chapter 1
The sql developer can add rules to the check that the data being added to the
table is valid, this chapter will show you ways to create various constraints.
Chapter 2
Templates are a useful sql server feature. We will show you how to use
Templates to speed up your sql development to save you time and create
consistency and also how to create your own sql server templates.
Chapter 3
When you start to develop more complex queries you can add them to stored
procedures so that they can be saved in the database and executed with a single 1
line statement at a later date.
We will cover to create stored procedures and pass parameters to the stored
procedures.
Chapter 4
Views allow you to hide complex SELECT statements so you only need to
run a simple select statements. Using View can save you copying and pasting
large chunks of code and make it easier to read the sql that you have developed.
Chapter 5
Next we will cover different types of functions that can be created and how
they compare to stored procedures.
Chapter 6
Synonyms are aliases for tables and are especially useful when you start to
develop code that uses references to multiple databases.
We will show you how to create and manage synonyms within your
database.
Chapter 7
Triggers allow you to execute some tsql when an action is taken on the
database or table. We will cover how to create various triggers and use them for
various purposes such as auditing and preventing users from creating tables.
Chapter 8
When you start to develop sql for large amounts of data the design of the
database will be increasingly more important. We will cover the fundamental
rules of database design called normal forms.
Chapter 9
Chapter 10
Finally we cover Transactions. Transactions are the 'all or nothing' in the sql
world. You might have a number of changes to tables within your stored
procedure but want all the changes to be saved as long as there has been no
errors executing any of the statements, transactions will allow to do this.
Section 1. Sql Server Install and Tour
1. Introduction
The purpose of this book is to teach the user sql database development.
More precisely you will learn sql development on Microsoft Sql Server using
the version of Sql from Microsoft called T-SQL (T-SQL stands for Transact
SQL).
With the Practical Series of books and 'Practical Sql' in this case you will be
guided from the basics to more advanced techniques.
The instructions are kept concise with the focus being on useful examples.
The aim here is that you will be more likely to remember what is said about a
topic and can always refer back to the examples at a later date if required.
Practical Sql
'Practical Sql' will cover the tsql development language used on the
Microsoft Sql Server Database system.
Sql Server Development is a topic that many IT Professionals avoid but there
really is no need as the basics and even more advanced techniques can be
acquired easily.
In other words Sql development is not a skill that will be of use to just DBA's
and developers.
There are many applications that rely on sql server databases so some
knowledge of databases it becoming a common requirement.
2. Sql Server Installation
You can download the current version of Sql Server Express from the
following location:
https://www.microsoft.com/en-gb/sql-server/sql-server-editions-express
Processor
RAM
Minimum 512MB
2. Click Install and wait for the installation files to be downloaded and
installed.
3. Once the installation has completed you will be presented with details
about your sql server. In particular make a note of your instance name
as this might be different from the screenshot below if you already
have a version of sql express on your machine:
4. To test your installation you can click the connect now button to
connect to the server as shown below:
5. Click Install SSMS and download the current version of the SSMS.
6. Once the download has completed, click the install and then click
install.
7. Click restart to complete the setup. Once your computer has restarted
you should be able to find the installed Sql Server Management Studio
by searching from the Start Menu:
3. Sql Server Tour
Before we get started learning sql server development we will give a brief
tour of the sql server environment itself.
This chapter will not turn you into a sql server database administrator but the
aim (especially if you are completely new to sql server) is to familiarise yourself
with some of the features, services and basic configuration of sql server.
The main sql server tool that your will be using for the configuration and
development tasks is called the 'Sql Server Management Studio' from now on
this will be referred to as SSMS.
The sql server runs using services, you can view these services in several
ways for example if you go to the Start Menu and search for Sql Server 2017
Configuration Manager.
Click on the Sql Server Services option and you will see the services that are
running
The main service for sql server. You will not be able to access sql server if
this service is not running.
This service allows you to perform various tasks including the scheduling of
jobs for example to backup your sql server databases or execute tsql at a
particular time.
From the sql server configuration manager you can configure each of these
services, for example if the start automatically and the account that is used to
run the service.
The account that is used to run services is important when the sql server
needs to access the filesystem for example when doing backup and restore tasks.
SQL Server Network Configuration
Within the Sql Server Network Configuration you can configure which
protocols can access your sql server.
The protocols are just different ways in which in which messages are sent to
and from your sql server installation.
The 3 protocols which we will cover next are Shared Memory, Named Pipes
and TCP/IP.
This protocol allows users running on the same computer to connect to the
sql server.
Named pipes are often used to allow applications and systems that do not use
TCP/IP to connect to the sql server
\\.\pipe\mytest
3. Go to Sql Server Services , right click on the SQL Server and select
restart.
4. Open SSMS and select Connect - Database Engine.
\\.\pipe\mytest
The reason for using named pipes is so that systems that do not use TCP/IP
can connect to your database.
This is the protocol that you will need to configure to allow your sql server
to be accessed from other machines on your network.
Protocol tab
IP Addresses tab
For example if you need your sql server to be accessed by another machine,
you would need to add the ip address and make sure it was set to active and
enabled, for example:
The default port for sql server is 1433, sql server express uses dynamic ports
by default
When using dynamic ports the port that the sql server uses changes when sql
server restarts.
TCP Port - if you wish to set a port that doesn't change you can enter the
port in the TCP Port field. No change is required here to follow the examples in
this book.
Sql Server Properties
There are various properties of the sql server that can be set using the SSMS.
To view the properties for your sql server installation right click on the Sql
server icon in the object explorer as shown and select Properties:
On the left hand side of the 'Server Properties' dialog that is displayed you
will see that the properties are divided into the following pages:
General
The general settings display various read-only properties such as the version
of the sql server and the version of the windows operating system.
You can also display the properties such tsql commands such as the
following:
SELECT
CONVERT(sysname, SERVERPROPERTY('servername')),
SERVERPROPERTY('ProductVersion') AS ProductVersion,
SERVERPROPERTY('ProductLevel') AS ProductLevel,
SERVERPROPERTY('Edition') AS Edition,
SERVERPROPERTY('EngineEdition') AS EngineEdition,
SERVERPROPERTY('Collation') AS Collation;
The result from this query should look similar to the following screenshot:
Memory
This page shows the sql server memory options, such as the minimum and
maximum amount of memory allowed to be used by the sql server.
Security
This page allows you to set whether Sql Authentication is allowed to be used
to login to the sql server. Windows authentication mode is the default setting.
Connections
The 'Allow remote connections to this server' is the most important option on
this page, especially if you have an application running on another server that
need to access your sql server database.
Database Settings
Here is where you set the default locations for the data (the sql server
database files), Log (sql server logs) and backups:
Data
Log
C:\Program Files\Microsoft SQL
Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\
Backup
Advanced
There are many options on this page. The most important to note at the
moment are:
Default language - make sure this correct for your country and be aware of
the differences between English (US) and British English. The default language
setting is used when creating new logins.
Permissions
The permissions page shows the commands various logins can execute on
the server.
For now if you select the login that you used to connect to the sql server,
then select the 'Effective' tab at the bottom of the page you will see a list of
permissions which are basically a list of things that this login can do while
connected to the sql server, for example:
If you select the login 'NT AUTHORITY\SYSTEM' you will see that the list
of effective permissions is more restricted that your login.
System databases
When you first install sql server there are 4 databases already created.
Random documents with unrelated
content Scribd suggests to you:
Authorities.—G. S. Layard, Life and Letters of Charles Keene of
“Punch”; The Work of Charles Keene, with an introduction and
notes by Joseph Pennell, and a bibliography by W. H. Chesson;
M. H. Spielmann, The History of “Punch”; M. Charpentier, La Vie
Moderne, No. 14 (1880); M. H. Spielmann, Magazine of Art
(March 1891); M. Bracquemond, L’Artiste (May 1891); G. S.
Layard, Scribner’s (April 1892); Joseph Pennell, Century (Oct.
1897); George du Maurier, Harper’s (March 1898). (G. S. I.)
The inhabitants are of three types. There is the true Kei Islander, a
Polynesian by his height and black or brown wavy hair, with a
complexion between the Papuan black and the Malay yellow. There
is the pure Papuan, who has been largely merged in the Kei type.
Thirdly, there are the immigrant Malays. These (distinguished by the
use of a special language and by the profession of
Mohammedanism) are descendants of natives of the Banda islands
who fled eastward before the encroachments of the Dutch. The
pagans have rude statues of deities and places of sacrifice indicated
by flat-topped cairns. The Kei Islanders are skilful in carving and
celebrated boat-builders.
See C. M. Kan, “Onze geographische kennis der Keij-Eilanden,”
in Tijdschrift Aardrijkskundig Genootschap (1887); Martin, “Die
Kei-inseln u. ihr Verhältniss zur Australisch-Asiatischen
Grenzlinie,” ibid. part vii. (1890); W. R. van Hoëvell, “De Kei-
Eilanden,” in Tijdschr. Batavian. Gen. (1889); “Verslagen van de
wetenschappelijke opnemingen en onderzoekingen op de Keij-
Eilanden” (1889-1890), by Planten and Wertheim (1893), with
map and ethnographical atlas of the south-western and south-
eastern islands by Pleyte; Langen, Die Key- oder Kii-Inseln
(Vienna, 1902).
Robert Keith (d. 1774), descended from a younger son of the 2nd
earl marishal, was British minister in Vienna in 1748, and
subsequently held other important diplomatic appointments, being
known to his numerous friends, among whom were the leading men
of letters of his time, as “Ambassador Keith.” His son, Sir Robert
Murray Keith (1730-1795), was on Lord George Sackville’s staff at
the battle of Minden. He became colonel of a regiment (the 87th
foot) known as Keith’s Highlanders, who won distinction in the
continental wars, but were disbanded in 1763; he was then
employed in the diplomatic service, in which he achieved
considerable success by his honesty, courage, and knowledge of
languages. In 1781 he became lieutenant-general; in 1789 he was
made a privy councillor.
From the Keith family through the female line was descended
George Keith Elphinstone, Baron Keith of Stonehaven, Marishal and
afterwards Viscount Keith (q.v.), whose titles became extinct at the
death of his daughter Margaret, Baroness Keith, in 1867.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com