SlideShare a Scribd company logo
1 of 24
Graeme Malcolm | Senior Content Developer, Microsoft
Geoff Allix | Principal Technologist, Content Master
Meet Your Instructors
Graeme Malcolm | @graeme_malcolm
– Senior content developer at Microsoft
– Consultant, trainer, and author since SQL Server 4.2
Geoff Allix | @GeoffAllix
– Principal Technologist at Content Master
– SQL Server specialist consultant, author, and trainer
Course Topics
Querying with Transact-SQL
01 | Introduction to Transact-SQL 07 | Using Table Expressions
02 | Querying Tables with SELECT 08 | Grouping Sets and Pivoting Data
03 | Querying Multiple Tables with Joins 09 | Modifying Data
04 | Using Set Operators 10 | Programming with Transact-SQL
05 | Using Functions and Aggregating Data 11 | Error Handling and Transactions
06 | Using Subqueries and APPLY
Setting Expectations
• Target Audience
– Aspiring database professionals
– Application developers
– Anyone preparing for SQL Server certification exams
• Course Materials
– Online video presentations
– Downloadable labs
• Suggested Approach
– Complete each module and lab in turn
– Engage with fellow students at Born To Learn
Course Lab Environment
• Labs are based on the AdventureWorksLT sample database in
Azure SQL Database
– Setup instructions are in the Getting Started guide
• There is a lab for each module, consisting of:
– Challenges based on the techniques discussed in the module
– References to relevant documentation
– Suggested solution scripts
DEMO
Using Azure SQL Database
SQL Server Training and Certification
• Microsoft Virtual Academy
– www.microsoftvirtualacademy.com
• Microsoft Official Curriculum
– www.microsoft.com/learning
• Microsoft Press
– www.microsoftpressstore.com
• Microsoft Certified Professional Program
– www.microsoft.com/learning
• Born to Learn
– borntolearn.mslearn.net
01 | Introduction to Transact-SQL
Graeme Malcolm | Senior Content Developer, Microsoft
Geoff Allix | Principal Technologist, Content Master
• What is Transact-SQL?
• Relational Databases
• Schemas and Object Names
• SQL Statement Types
• The SELECT Statement
• Working with Data Types
• Working with NULLs
Module Overview
What is Transact-SQL?
• Structured Query Language (SQL)
– Developed by IBM in 1970s
– Adopted as a standard by ANSI and ISO standards bodies
– Widely used in industry
• Microsoft’s implementation is Transact-SQL
– Referred to as T-SQL
– Query language for SQL Server and Azure SQL Database
• SQL is declarative, not procedural
– Describe what you want, don’t specify steps
SalesOrderDetail
OrderID LineItemNo ProductID Quantity
1 1 3 1
2 1 2 5
2 2 3 1
3 1 1 1
Relational Databases
• Entities are represented as relations (tables), in which their
attributes are represented as domains (columns)
• Most relational databases are normalized, with relationships
defined between tables through primary and foreign keys
Customer
CustomerID FirstName LastName
1 Dan Drayton
2 Aisha Witt
3 Rosie Reeves
Product
ProductID Name ListPrice
1 Widget 2.99
2 Gizmo 1.79
3 Thingybob 3.49
SalesOrderHeader
OrderID OrderDate CustomerID
1 1/1/2015 1
2 1/1/2015 3
3 1/2/2015 1
Schemas and Object Names
• Schemas are namespaces for database objects
• Fully-qualified names:
[server_name.][database_name.][schema_name.]object_name
• Within database context, best practice is to include schema
name:
schema_name.object_name
Sales Production
Order
Customer
Product
Order
Sales.Order
Sales.Customer
Production.Product
Production.Order
SQL Statement Types
Data Manipulation Language (DML) Data Definition Language (DDL) Data Control Language (DCL)
Statements for querying and
modifying data:
• SELECT
• INSERT
• UPDATE
• DELETE
Statements for defining
database objects:
• CREATE
• ALTER
• DROP
Statements for assigning
security permissions:
• GRANT
• REVOKE
• DENY
Focus of this course
The SELECT Statement
Element Expression Role
SELECT <select list> Defines which columns to return
FROM <table source> Defines table(s) to query
WHERE <search condition> Filters rows using a predicate
GROUP BY <group by list> Arranges rows by groups
HAVING <search condition> Filters groups using a predicate
ORDER BY <order by list> Sorts the output
5
1
2
3
4
6
SELECT OrderDate, COUNT(OrderID)
FROM Sales.SalesOrder
WHERE Status = 'Shipped'
GROUP BY OrderDate
HAVING COUNT(OrderID) > 1
ORDER BY OrderDate DESC;
Basic SELECT Query Examples
• All columns
• Specific columns
• Expressions and Aliases
SELECT * FROM Production.Product;
SELECT Name, ListPrice
FROM Production.Product;
SELECT Name AS Product, ListPrice * 0.9 AS SalePrice
FROM Production.Product;
DEMO
Basic SELECT Queries
Working with Data Types
Transact-SQL Data Types
Exact Numeric Approximate Numeric Character Date/Time Binary Other
tinyint float char date binary cursor
smallint real varchar time varbinary hierarchyid
int text datetime image sql_variant
bigint nchar datetime2 table
bit nvarchar smalldatetime timestamp
decimal/numeric ntext datetimeoffset uniqueidentifier
numeric xml
money geography
smallmoney geometry
Working with Data Types
Data Type Conversion
• Implicit Conversion
– Compatible data types can be automatically converted
• Explicit Conversion
– Requires an explicit conversion function
• CAST / TRY_CAST
• CONVERT / TRY_CONVERT
• PARSE / TRY_PARSE
• STR
DEMO
Converting Data Types
Working with NULLs
NULL Values
• NULL represents a missing or unknown value
• ANSI behaviour for NULL values:
– The result of any expression containing a NULL value is NULL
• 2 + NULL = NULL
• ‘MyString: ‘ + NULL = NULL
– Equality comparisons always return false for NULL values
• NULL = NULL returns false
• NULL IS NULL returns true
Working with NULLs
NULL Functions
• ISNULL(column/variable, value)
– Returns value if the column or variable is NULL
• NULLIF(column/variable, value)
– Returns NULL if the column or variable is value
• COALESCE (column/variable1, column/variable2,…)
– Returns the value of the first non-NULL column or variable in the list
DEMO
Working with NULLs
• What is Transact-SQL?
• Relational Databases
• Schemas and Object Names
• SQL Statement Types
• The SELECT Statement
• Working with Data Types
• Working with NULLs
• Lab: Introduction to Transact-SQL
Introduction to Transact-SQL
©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the
U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft
must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after
the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related Content

Similar to Querying_with_T-SQL_-_01.pptx

Less07 schema
Less07 schemaLess07 schema
Less07 schemaImran Ali
 
Rajnish singh(presentation on oracle )
Rajnish singh(presentation on  oracle )Rajnish singh(presentation on  oracle )
Rajnish singh(presentation on oracle )Rajput Rajnish
 
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQLTaming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQLMichael Rys
 
An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1Navneet Upneja
 
Web Cloud Computing SQL Server - Ferrara University
Web Cloud Computing SQL Server  -  Ferrara UniversityWeb Cloud Computing SQL Server  -  Ferrara University
Web Cloud Computing SQL Server - Ferrara Universityantimo musone
 
SQL Server Workshop for Developers - Visual Studio Live! NY 2012
SQL Server Workshop for Developers - Visual Studio Live! NY 2012SQL Server Workshop for Developers - Visual Studio Live! NY 2012
SQL Server Workshop for Developers - Visual Studio Live! NY 2012Andrew Brust
 
Sterling for Windows Phone 7
Sterling for Windows Phone 7Sterling for Windows Phone 7
Sterling for Windows Phone 7Jeremy Likness
 
Test labs 2016. Тестирование data warehouse
Test labs 2016. Тестирование data warehouse Test labs 2016. Тестирование data warehouse
Test labs 2016. Тестирование data warehouse Sasha Soleev
 
Presenter manual oracle D2K (specially for summer interns)
Presenter manual oracle D2K (specially for summer interns)Presenter manual oracle D2K (specially for summer interns)
Presenter manual oracle D2K (specially for summer interns)XPERT INFOTECH
 
122 sql for-beginners
122 sql for-beginners122 sql for-beginners
122 sql for-beginnerssuzzanj1990
 
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Michael Rys
 
SQLDay2013_Denny Cherry - Table indexing for the .NET Developer
SQLDay2013_Denny Cherry - Table indexing for the .NET DeveloperSQLDay2013_Denny Cherry - Table indexing for the .NET Developer
SQLDay2013_Denny Cherry - Table indexing for the .NET DeveloperPolish SQL Server User Group
 
Efficient working with Databases in LabVIEW - Sam Sharp (MediaMongrels Ltd) -...
Efficient working with Databases in LabVIEW - Sam Sharp (MediaMongrels Ltd) -...Efficient working with Databases in LabVIEW - Sam Sharp (MediaMongrels Ltd) -...
Efficient working with Databases in LabVIEW - Sam Sharp (MediaMongrels Ltd) -...MediaMongrels Ltd
 

Similar to Querying_with_T-SQL_-_01.pptx (20)

Less07 schema
Less07 schemaLess07 schema
Less07 schema
 
Rajnish singh(presentation on oracle )
Rajnish singh(presentation on  oracle )Rajnish singh(presentation on  oracle )
Rajnish singh(presentation on oracle )
 
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQLTaming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
 
An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1
 
IR SQLite Session #1
IR SQLite Session #1IR SQLite Session #1
IR SQLite Session #1
 
ow.ppt
ow.pptow.ppt
ow.ppt
 
ow.ppt
ow.pptow.ppt
ow.ppt
 
Ow
OwOw
Ow
 
Web Cloud Computing SQL Server - Ferrara University
Web Cloud Computing SQL Server  -  Ferrara UniversityWeb Cloud Computing SQL Server  -  Ferrara University
Web Cloud Computing SQL Server - Ferrara University
 
Resume_of_sayeed
Resume_of_sayeedResume_of_sayeed
Resume_of_sayeed
 
SQL Server Workshop for Developers - Visual Studio Live! NY 2012
SQL Server Workshop for Developers - Visual Studio Live! NY 2012SQL Server Workshop for Developers - Visual Studio Live! NY 2012
SQL Server Workshop for Developers - Visual Studio Live! NY 2012
 
SQL Intro
SQL IntroSQL Intro
SQL Intro
 
Sterling for Windows Phone 7
Sterling for Windows Phone 7Sterling for Windows Phone 7
Sterling for Windows Phone 7
 
Test labs 2016. Тестирование data warehouse
Test labs 2016. Тестирование data warehouse Test labs 2016. Тестирование data warehouse
Test labs 2016. Тестирование data warehouse
 
Presenter manual oracle D2K (specially for summer interns)
Presenter manual oracle D2K (specially for summer interns)Presenter manual oracle D2K (specially for summer interns)
Presenter manual oracle D2K (specially for summer interns)
 
Using T-SQL
Using T-SQL Using T-SQL
Using T-SQL
 
122 sql for-beginners
122 sql for-beginners122 sql for-beginners
122 sql for-beginners
 
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
 
SQLDay2013_Denny Cherry - Table indexing for the .NET Developer
SQLDay2013_Denny Cherry - Table indexing for the .NET DeveloperSQLDay2013_Denny Cherry - Table indexing for the .NET Developer
SQLDay2013_Denny Cherry - Table indexing for the .NET Developer
 
Efficient working with Databases in LabVIEW - Sam Sharp (MediaMongrels Ltd) -...
Efficient working with Databases in LabVIEW - Sam Sharp (MediaMongrels Ltd) -...Efficient working with Databases in LabVIEW - Sam Sharp (MediaMongrels Ltd) -...
Efficient working with Databases in LabVIEW - Sam Sharp (MediaMongrels Ltd) -...
 

More from QuyVo27

PHP-Basic
PHP-BasicPHP-Basic
PHP-BasicQuyVo27
 
Tong quan benh xuong khop
Tong quan benh xuong khopTong quan benh xuong khop
Tong quan benh xuong khopQuyVo27
 
Medical image procesing
Medical image procesingMedical image procesing
Medical image procesingQuyVo27
 
b6-190213084710.pdf
b6-190213084710.pdfb6-190213084710.pdf
b6-190213084710.pdfQuyVo27
 
b5-viewproc-190213084706.pdf
b5-viewproc-190213084706.pdfb5-viewproc-190213084706.pdf
b5-viewproc-190213084706.pdfQuyVo27
 
b34-dml-sql-190213084703.pdf
b34-dml-sql-190213084703.pdfb34-dml-sql-190213084703.pdf
b34-dml-sql-190213084703.pdfQuyVo27
 
b2-ddl-create-190213085738.pdf
b2-ddl-create-190213085738.pdfb2-ddl-create-190213085738.pdf
b2-ddl-create-190213085738.pdfQuyVo27
 
b2-ddl-create-190213084659.pdf
b2-ddl-create-190213084659.pdfb2-ddl-create-190213084659.pdf
b2-ddl-create-190213084659.pdfQuyVo27
 
b1-gioithieu-190213084421.pdf
b1-gioithieu-190213084421.pdfb1-gioithieu-190213084421.pdf
b1-gioithieu-190213084421.pdfQuyVo27
 
SQL Server 2014 – Features Drilldown.pptx
SQL Server 2014 – Features Drilldown.pptxSQL Server 2014 – Features Drilldown.pptx
SQL Server 2014 – Features Drilldown.pptxQuyVo27
 
SQL Server 2019 Modern Data Platform.pptx
SQL Server 2019 Modern Data Platform.pptxSQL Server 2019 Modern Data Platform.pptx
SQL Server 2019 Modern Data Platform.pptxQuyVo27
 
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxQuyVo27
 
SQL Server 2016 - Always On.pptx
SQL Server 2016 - Always On.pptxSQL Server 2016 - Always On.pptx
SQL Server 2016 - Always On.pptxQuyVo27
 
MS SQL Server.ppt
MS SQL Server.pptMS SQL Server.ppt
MS SQL Server.pptQuyVo27
 

More from QuyVo27 (14)

PHP-Basic
PHP-BasicPHP-Basic
PHP-Basic
 
Tong quan benh xuong khop
Tong quan benh xuong khopTong quan benh xuong khop
Tong quan benh xuong khop
 
Medical image procesing
Medical image procesingMedical image procesing
Medical image procesing
 
b6-190213084710.pdf
b6-190213084710.pdfb6-190213084710.pdf
b6-190213084710.pdf
 
b5-viewproc-190213084706.pdf
b5-viewproc-190213084706.pdfb5-viewproc-190213084706.pdf
b5-viewproc-190213084706.pdf
 
b34-dml-sql-190213084703.pdf
b34-dml-sql-190213084703.pdfb34-dml-sql-190213084703.pdf
b34-dml-sql-190213084703.pdf
 
b2-ddl-create-190213085738.pdf
b2-ddl-create-190213085738.pdfb2-ddl-create-190213085738.pdf
b2-ddl-create-190213085738.pdf
 
b2-ddl-create-190213084659.pdf
b2-ddl-create-190213084659.pdfb2-ddl-create-190213084659.pdf
b2-ddl-create-190213084659.pdf
 
b1-gioithieu-190213084421.pdf
b1-gioithieu-190213084421.pdfb1-gioithieu-190213084421.pdf
b1-gioithieu-190213084421.pdf
 
SQL Server 2014 – Features Drilldown.pptx
SQL Server 2014 – Features Drilldown.pptxSQL Server 2014 – Features Drilldown.pptx
SQL Server 2014 – Features Drilldown.pptx
 
SQL Server 2019 Modern Data Platform.pptx
SQL Server 2019 Modern Data Platform.pptxSQL Server 2019 Modern Data Platform.pptx
SQL Server 2019 Modern Data Platform.pptx
 
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptx
 
SQL Server 2016 - Always On.pptx
SQL Server 2016 - Always On.pptxSQL Server 2016 - Always On.pptx
SQL Server 2016 - Always On.pptx
 
MS SQL Server.ppt
MS SQL Server.pptMS SQL Server.ppt
MS SQL Server.ppt
 

Recently uploaded

办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...Boston Institute of Analytics
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queensdataanalyticsqueen03
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改yuu sss
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.natarajan8993
 
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degreeyuu sss
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 

Recently uploaded (20)

办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queens
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.
 
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 

Querying_with_T-SQL_-_01.pptx

  • 1. Graeme Malcolm | Senior Content Developer, Microsoft Geoff Allix | Principal Technologist, Content Master
  • 2. Meet Your Instructors Graeme Malcolm | @graeme_malcolm – Senior content developer at Microsoft – Consultant, trainer, and author since SQL Server 4.2 Geoff Allix | @GeoffAllix – Principal Technologist at Content Master – SQL Server specialist consultant, author, and trainer
  • 3. Course Topics Querying with Transact-SQL 01 | Introduction to Transact-SQL 07 | Using Table Expressions 02 | Querying Tables with SELECT 08 | Grouping Sets and Pivoting Data 03 | Querying Multiple Tables with Joins 09 | Modifying Data 04 | Using Set Operators 10 | Programming with Transact-SQL 05 | Using Functions and Aggregating Data 11 | Error Handling and Transactions 06 | Using Subqueries and APPLY
  • 4. Setting Expectations • Target Audience – Aspiring database professionals – Application developers – Anyone preparing for SQL Server certification exams • Course Materials – Online video presentations – Downloadable labs • Suggested Approach – Complete each module and lab in turn – Engage with fellow students at Born To Learn
  • 5. Course Lab Environment • Labs are based on the AdventureWorksLT sample database in Azure SQL Database – Setup instructions are in the Getting Started guide • There is a lab for each module, consisting of: – Challenges based on the techniques discussed in the module – References to relevant documentation – Suggested solution scripts
  • 7. SQL Server Training and Certification • Microsoft Virtual Academy – www.microsoftvirtualacademy.com • Microsoft Official Curriculum – www.microsoft.com/learning • Microsoft Press – www.microsoftpressstore.com • Microsoft Certified Professional Program – www.microsoft.com/learning • Born to Learn – borntolearn.mslearn.net
  • 8. 01 | Introduction to Transact-SQL Graeme Malcolm | Senior Content Developer, Microsoft Geoff Allix | Principal Technologist, Content Master
  • 9. • What is Transact-SQL? • Relational Databases • Schemas and Object Names • SQL Statement Types • The SELECT Statement • Working with Data Types • Working with NULLs Module Overview
  • 10. What is Transact-SQL? • Structured Query Language (SQL) – Developed by IBM in 1970s – Adopted as a standard by ANSI and ISO standards bodies – Widely used in industry • Microsoft’s implementation is Transact-SQL – Referred to as T-SQL – Query language for SQL Server and Azure SQL Database • SQL is declarative, not procedural – Describe what you want, don’t specify steps
  • 11. SalesOrderDetail OrderID LineItemNo ProductID Quantity 1 1 3 1 2 1 2 5 2 2 3 1 3 1 1 1 Relational Databases • Entities are represented as relations (tables), in which their attributes are represented as domains (columns) • Most relational databases are normalized, with relationships defined between tables through primary and foreign keys Customer CustomerID FirstName LastName 1 Dan Drayton 2 Aisha Witt 3 Rosie Reeves Product ProductID Name ListPrice 1 Widget 2.99 2 Gizmo 1.79 3 Thingybob 3.49 SalesOrderHeader OrderID OrderDate CustomerID 1 1/1/2015 1 2 1/1/2015 3 3 1/2/2015 1
  • 12. Schemas and Object Names • Schemas are namespaces for database objects • Fully-qualified names: [server_name.][database_name.][schema_name.]object_name • Within database context, best practice is to include schema name: schema_name.object_name Sales Production Order Customer Product Order Sales.Order Sales.Customer Production.Product Production.Order
  • 13. SQL Statement Types Data Manipulation Language (DML) Data Definition Language (DDL) Data Control Language (DCL) Statements for querying and modifying data: • SELECT • INSERT • UPDATE • DELETE Statements for defining database objects: • CREATE • ALTER • DROP Statements for assigning security permissions: • GRANT • REVOKE • DENY Focus of this course
  • 14. The SELECT Statement Element Expression Role SELECT <select list> Defines which columns to return FROM <table source> Defines table(s) to query WHERE <search condition> Filters rows using a predicate GROUP BY <group by list> Arranges rows by groups HAVING <search condition> Filters groups using a predicate ORDER BY <order by list> Sorts the output 5 1 2 3 4 6 SELECT OrderDate, COUNT(OrderID) FROM Sales.SalesOrder WHERE Status = 'Shipped' GROUP BY OrderDate HAVING COUNT(OrderID) > 1 ORDER BY OrderDate DESC;
  • 15. Basic SELECT Query Examples • All columns • Specific columns • Expressions and Aliases SELECT * FROM Production.Product; SELECT Name, ListPrice FROM Production.Product; SELECT Name AS Product, ListPrice * 0.9 AS SalePrice FROM Production.Product;
  • 17. Working with Data Types Transact-SQL Data Types Exact Numeric Approximate Numeric Character Date/Time Binary Other tinyint float char date binary cursor smallint real varchar time varbinary hierarchyid int text datetime image sql_variant bigint nchar datetime2 table bit nvarchar smalldatetime timestamp decimal/numeric ntext datetimeoffset uniqueidentifier numeric xml money geography smallmoney geometry
  • 18. Working with Data Types Data Type Conversion • Implicit Conversion – Compatible data types can be automatically converted • Explicit Conversion – Requires an explicit conversion function • CAST / TRY_CAST • CONVERT / TRY_CONVERT • PARSE / TRY_PARSE • STR
  • 20. Working with NULLs NULL Values • NULL represents a missing or unknown value • ANSI behaviour for NULL values: – The result of any expression containing a NULL value is NULL • 2 + NULL = NULL • ‘MyString: ‘ + NULL = NULL – Equality comparisons always return false for NULL values • NULL = NULL returns false • NULL IS NULL returns true
  • 21. Working with NULLs NULL Functions • ISNULL(column/variable, value) – Returns value if the column or variable is NULL • NULLIF(column/variable, value) – Returns NULL if the column or variable is value • COALESCE (column/variable1, column/variable2,…) – Returns the value of the first non-NULL column or variable in the list
  • 23. • What is Transact-SQL? • Relational Databases • Schemas and Object Names • SQL Statement Types • The SELECT Statement • Working with Data Types • Working with NULLs • Lab: Introduction to Transact-SQL Introduction to Transact-SQL
  • 24. ©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Editor's Notes

  1. 1
  2. 8