version 1.0. mcad mcsd mcpd enterprise sql mcts mct software/web development consultant...

20
Querying Microsoft SQL Server 2012 Version 1.0

Upload: reynard-berry

Post on 27-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Querying Microsoft SQL Server 2012

Version 1.0

• MCAD• MCSD• MCPD Enterprise• SQL MCTS• MCT• Software/Web Development Consultant• Cryptography/Digital Signature Consultant• SQL Server 2005/2008R2/2012 Consultant• SharePoint 2007/2010/2013 Consultant• AJAX Consultant• Software Development Lead• Professional Scrum Master

Ahmad Adel [email protected]

Author

Course Outline1. Overview2. Select Statement - Retrieve Data3. Select Statement - Filtering Data4. Working with NULL Values5. Formatting Result Sets6. System Functions7. Combining and Limiting Result Sets8. Grouping Data9. Using Table Expressions

Querying Microsoft SQL Server 2012 - Ahmad Adel

Course Outline10.Windowing and Paging Data (Over Clause)11.Querying SQL Server Metadata11.Data Manipulation Language (DML)12.Querying Full-Text Index Search13.Distributed Queries15.Implementing

Error Handling (Handling Exceptions)16.Implementing Transactions (TCL)

Querying Microsoft SQL Server 2012 - Ahmad Adel

Overview

• About SQL Language (T-SQL)• Introduction to Microsoft SQL Server 2012

Querying Microsoft SQL Server 2012 - Ahmad Adel

Select Statement - Retrieve Data• Fixed Values• Variables• Calculated Values• All Fields From Specific Table• Specific Fields From Specific Table• Concatenated Fields - Alias Name• Calculated Value On Specific Fields• Specific Columns From Table Alias Name• Value Returned From Function

Querying Microsoft SQL Server 2012 - Ahmad Adel

Select Statement - Filtering Data

• Comparison operators• Logical operators

Querying Microsoft SQL Server 2012 - Ahmad Adel

Working with NULL Values

• IS Null - Comparison• ANSI_NULLS Settings• ISNULL() Function• NullIF() Function• Coalesce() Function

Querying Microsoft SQL Server 2012 - Ahmad Adel

Formatting Result Sets

• Sorting Data• Eliminating Duplicate Rows

Querying Microsoft SQL Server 2012 - Ahmad Adel

System Functions

• Aggregate Functions• Scalar Functions• Converting Functions

Querying Microsoft SQL Server 2012 - Ahmad Adel

Combining and Limiting Result Sets• Join• Inner/Where Clause• Outer (Full/Left/Right)• Cross• Self Join

• Data Samples (TableSample Operator)• Cube• Union/Except/Intersect• Apply (Cross/Outer)

Querying Microsoft SQL Server 2012 - Ahmad Adel

Grouping Data

• Group By• RollUP• Cube• Pivot - UnPivot

Querying Microsoft SQL Server 2012 - Ahmad Adel

Using Table Expressions

• Sub Queries• Derived Tables• Common Table Expressions (CTE)• Views• Table-Valued Functions

Querying Microsoft SQL Server 2012 - Ahmad Adel

Windowing and Paging Data (Over Clause)• Paging Functions• Offset – Fetch• Row_Number

• Over Clause• Ranking Functions• Analytic Functions• Aggregate Functions• NEXT VALUE FOR

Querying Microsoft SQL Server 2012 - Ahmad Adel

Querying SQL Server Metadata

• System Variable• System Stored Procedures• System Catalog Views• System Catalog Functions• Dynamic Management Views (DMV)• Dynamic Management Functions (DMF)

Querying Microsoft SQL Server 2012 - Ahmad Adel

Data Manipulation Language (DML)

• Insert• Update• Delete• Output Clause

Querying Microsoft SQL Server 2012 - Ahmad Adel

Querying Full-Text Index Search

• Contains• FreeText

Querying Microsoft SQL Server 2012 - Ahmad Adel

Distributed Queries

• OpenDataSource Function• OpenRowSet Function• Configure 'Ad Hoc Distributed Queries' Settings

Querying Microsoft SQL Server 2012 - Ahmad Adel

Implementing Error Handling (Handling Exceptions)

• @@Error Variable• Try … Catch• Throw Exceptions• RaiseError• Throw

• System Error Information Functions• Error Severities

Querying Microsoft SQL Server 2012 - Ahmad Adel

Implementing Transactions (TCL)

• Autocommit Transactions• Implicit Transactions• Explicit Transactions• XACT_ABORT Setting• Implementing Transactions with Exception Handling• XACT_STATE() Function• Isolation Levels

Querying Microsoft SQL Server 2012 - Ahmad Adel