Upload
chowdhury-golam-kibria
View
8
Download
3
Embed Size (px)
DESCRIPTION
Introductory concepts n SQL Server 2012
Citation preview
SYED SAJID WASIM
Ex-AVP, DHAKABANK Limited
Ex-Sr. Database Engineer, Orion Informatics Limited
Focused on database and development technologies
MCP, MCTS, MCSE on Data Platform & Administration
Working with SQL Server since version 6.5
01 | Introduction to SQL Server
Querying Microsoft SQL Server 2012 Jump Start
01 | Introducing SQL Server 2012
SQL Server types of statements; other SQL statement elements; basic SELECT statements
02 | Advanced SELECT StatementsDISTINCT, Aliases, scalar functions and CASE, using JOIN and MERGE; Filtering and sorting data, NULL
values
03 | SQL Server Data Types Introduce data types, data type usage, converting data types, understanding SQL Server function types
04 | Grouping and Aggregating DataAggregate functions, GROUP BY and HAVING clauses, subqueries; self-contained, correlated, and EXISTS; Views, inline-table
valued functions, and derived tables
Querying Microsoft SQL Server 2012 Jump Start
05 | SET Operators, Windows Functions, and Grouping SET operators, Windows functions, GROUPING sets (PIVOT, UNPIVOT, CUBE, ROLLUP)
06 | Modifying Data INSERT, UPDATE, and DELETE statements, use of defaults, constraints, and triggers, OUTPUT
07 | Programming with T-SQL Using T-SQL programming elements, implementing error handling, understanding and implementing transactions
08 | Retrieving SQL Server Metadata and Improving Query Performance Querying system catalogs and dynamic management views, creating and executing stored procedures, improving SQL
Server query performance
Statements for querying and modifying data
SELECT, INSERT, UPDATE, DELETE
Statements for object definitions
CREATE, ALTER, DROP
Statements for security permissions
GRANT, REVOKE, DENY
Data Manipulation Language (DML*)
Data Definition Language (DDL)
Data Control Language (DCL)
* DML with SELECT is the primary focus of this course
Categories of T-SQL statements
Predicates and Operators
Control of FlowFunctions
Expressions
Variables Comments
Batch Separators
T-SQL language elements
Elements: Predicates and Operators:
Predicates IN, BETWEEN, LIKE
Comparison Operators =, >, =, , !<
Logical Operators AND, OR, NOT
Arithmetic Operators +, -, *, /, %
Concatenation +
T-SQL enforces operator precedence
SUBSTRING LEFT, RIGHT LEN DATALENGTH REPLACE REPLICATE UPPER, LOWER RTRIM, LTRIM
GETDATE SYSTDATETIME GETUTCDATE DATEADD DATEDIFF YEAR MONTH DAY
SUM MIN MAX AVG COUNT
String FunctionsDate and Time Functions
Aggregate Functions
T-SQL language elements: functions
DECLARE @MyVar int = 30;
T-SQL language elements: expressions
SELECT YEAR(OrderDate) + 1 ...
SELECT OrderQty * UnitPrice ...
TRY...CATCH IF...ELSE WHILE BREAK CONTINUE BEGIN...END
BEGIN TRANSACTION
COMMIT TRANSACTION
ROLLBACK TRANSACTION
Control of Flow Error Handling Transaction Control
/* This is a block
of commented code*/
-- This line of text will be ignored
Logical query processing
5: SELECT
1: FROM
2: WHERE
3: GROUP BY
4: HAVING
6: ORDER BY
USE AdventureWorks2012;
SELECT SalesPersonID, YEAR(OrderDate) AS OrderYearFROM Sales.SalesOrderHeaderWHERE CustomerID = 29974GROUP BY SalesPersonID, YEAR(OrderDate)HAVING COUNT(*) > 1ORDER BY SalesPersonID, OrderYear;
Applying the logical order of operations to writing SELECT statements
USE AdventureWorks2012;
SELECT SalesPersonID, YEAR(OrderDate) AS OrderYearFROM Sales.SalesOrderHeaderWHERE CustomerID = 29974GROUP BY SalesPersonID, YEAR(OrderDate)HAVING COUNT(*) > 1ORDER BY SalesPersonID, OrderYear;
Clause Expression
SELECT
FROM
WHERE
GROUP BY
ORDER BY
SELECT CustomerID, StoreID
FROM Sales.Customer;
Keyword Expression
SELECT
FROM
SELECT unitprice, OrderQty, (unitprice * OrderQty)
FROM sales.salesorderdetail;
Operator Description
+ Add or concatenate
- Subtract
* Multiply
/ Divide
% Modulo
2013 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.