SlideShare a Scribd company logo
itcampro@ itcamp13# Premium conference on Microsoft technologies
Transact-SQL from 0 to SQL
Server 2012
Cristian Lefter
SQL Server MVP
http://about.me/CristianLefter
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best PracticesHuge thanks to our sponsors!
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• Introduction
• SQL Server 20XX
• Next Steps
Agenda
itcampro@ itcamp13# Premium conference on Microsoft technologies
INSTEAD OF AN
INTRODUCTION
Section 1
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• Initially developed at IBM by Donald D. Chamberlin and
Raymond F. Boyce in the early 1970s under the name of
SEQUEL (Structured English Query Language)
• Designed to manipulate and retrieve data stored in IBM's
original quasi-relational database management system, System
R
• Based on Edgar F. Codd's relational model, described in his
1970 paper "A Relational Model of Data for Large Shared Data
Banks”
• Was renamed SQL because "SEQUEL" was a trademark of an
UK-based aircraft company.
• SQL becomes a standard of the American National Standards
Institute (ANSI) in 1986 and for International Organization for
Standards (ISO) in 1987
SQL - history
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
Version Year Release Name Codename
1.0
(OS/2)
1989 SQL Server 1.0
(16 bit)
-
1.1
(OS/2)
1991 SQL Server 1.1
(16 bit)
-
4.21
(WinNT)
1993 SQL Server 4.21 SQLNT
6.0 1995 SQL Server 6.0 SQL95
6.5 1996 SQL Server 6.5 Hydra
7.0 1998 SQL Server 7.0 Sphinx
- 1999 SQL Server 7.0
OLAP Tools
Plato mania
Microsoft SQL Server History
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
Version Year Release Name Codename
8.0 2000 SQL Server 2000 Shiloh
8.0 2003 SQL Server 2000
64-bit Edition
Liberty
9.0 2005 SQL Server 2005 Yukon
10.0 2008 SQL Server 2008 Katmai
10.25 2010 SQL Azure DB CloudDatabase
10.5 2010 SQL Server 2008
R2
Kilimanjaro (aka KJ)
11.0 2012 SQL Server 2012 Denali
Microsoft SQL Server History (cont.)
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best PracticesVersion 1.0
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best PracticesVersion 1.1 on OS/2 – SQL Admin Facility
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
What is a database?
A collection of objects known as tables. For the
OS, a database is simply a file.
What is a table?
A table is a set of data elements (values) that is
organized using a model of vertical columns
(which are identified by their name) and
horizontal rows.
Database related terms
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• Are these familiar to you?
– SELECT / INSERT / UPDATE / DELETE
• How about these?
– GROUP BY, PROCEDURE, FUNCTION, TRIGGER
Where Do We Start From?
itcampro@ itcamp13# Premium conference on Microsoft technologies
SQL SERVER 2000
Section 2
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• XML support - FOR XML clause
• User-Defined Functions
• Indexed Views
• INSTEAD OF and AFTER triggers
New in SQL Server 2000
itcampro@ itcamp13# Premium conference on Microsoft technologies
SQL SERVER 2005
Section 2
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
Syntax:
Common Table Expressions (CTE)
WITH <common_table_expression> [ ,...n ]
<common_table_expression>::=
expression_name [ ( column_name [
,...n ] )]
AS ( CTE_query_definition )
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
Syntax:
OUTPUT clause
OUTPUT <dml_select_list> INTO {
@table_variable | output_table } [ (
column_list ) ]
[ OUTPUT <dml_select_list> ]
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• CROSS APPLY
• OUTER APPLY
Syntax:
APPLY operator
FROM left_table_source
{OUTER | CROSS} APPLY right_table_source
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
Partial Syntax:
PIVOT and UNPIVOT operators
SELECT * FROM table_source
PIVOT (aggregate_function ( value_column )
FOR pivot_column IN ( <column_list> )
) table_alias
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• CREATE LOGIN,
• ALTER LOGIN
• DROP LOGIN
• CREATE USER
• ALTER USER
• DROP USER
Security Statements
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
Syntax:
Error Handling
BEGIN TRY
{ sql_statement | statement_block }
END TRY
BEGIN CATCH
{ sql_statement | statement_block }
END CATCH
[ ; ]
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• RANK
• DENSE_RANK
• NTILE
• ROW_NUMBER
Ranking Functions
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• .NET Integration
• XML support (xml data type, XQUERY
support, XML Data Manipulation
Language, XML Schemas support)
• VARCHAR(MAX), VARBINARY(MAX)
• Execution context – EXECUTE AS
• Schemas
Other things to mention
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• Full-text Search DDL
– CREATE FULLTEXT CATALOG
– CREATE FULLTEXT INDEX
• DDL Triggers
• Event Notifications
• Service Broker
– SEND
– RECEIVE
• Partitioning
– CREATE PARTITION FUNCTION
– CREATE PARTITION SCHEME
– CREATE TABLE table_name ON partition_scheme_name
(column_name)
Other things to mention (cont.)
itcampro@ itcamp13# Premium conference on Microsoft technologies
SQL SERVER 2008
Section 3
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• Row Constructors
• One statement variable
declaration/assignment
• Compound assignment operators
T-SQL delighters
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
Syntax:
INSERT over DML
OUTPUT <dml_select_list> INTO{
@table_variable|output_table}
[(column_list)]][OUTPUT<dml_select_list>]
<dml_select_list> ::=
{ <column_name> | scalar_expression } [ [AS]
column_alias_identifier ][ ,...n ]
<column_name> ::={DELETED|INSERTED|
from_table_name}.{*|column_name}|$ACTION
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
Example of usage:
Table-valued parameters
CREATE TABLE StockTransactions(TransactionID INT PRIMARY KEY
IDENTITY(1,1),StockSymbol VARCHAR(64),Qty INT);
GO
CREATE TYPE TransactionType AS TABLE (StockSymbol VARCHAR(64),
Qty INT);
GO
CREATE PROCEDURE usp_InsertTransaction
@TVP TransactionType READONLY
AS
BEGIN
SET NOCOUNT ON
INSERT INTO StockTransactions(StockSymbol,Qty)
SELECT StockSymbol,Qty FROM @TVP;
END;
GO
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
Partial syntax:
MERGE statement
MERGE
[INTO] target_table
USING <table_source>
ON <search_condition>
[WHEN MATCHED [AND <search_condition>]
THEN <merge_matched>]
[WHEN [TARGET] NOT MATCHED [AND <search_condition>]
THEN <merge_not_matched>]
[WHEN SOURCE NOT MATCHED [AND <search_condition>]
THEN <merge_matched>]
<output_clause>;
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• DATE
• TIME
• DATETIME2
• DATETIMEOFFSET
Date and Time Data Types
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• Sparse Columns and Column Sets
• HierarchyID data type
• GROUP BY Enhancements
• Resource Governor
• Transparent Data Encryption
• SQL Server Audit
• Extended Events
• Data Compression
• Backup Compression
Other things to mention
itcampro@ itcamp13# Premium conference on Microsoft technologies
SQL SERVER 2008 R2
Section 4
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• Nothing major for T-SQL except UNICODE
compression
SQL Server 2008 R2
itcampro@ itcamp13# Premium conference on Microsoft technologies
SQL SERVER 2012
Section 4
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best PracticesQuery Pagination
Syntax:
Example:
OFFSET <offset_value> ROW|ROWS
FETCH FIRST|NEXT <fetch_value> ROW|ROWS
[ONLY]
SELECT ProductID, Name,Color, Size
FROM Production.Product
ORDER BY Color,ProductID ASC
OFFSET 100 ROWS
FETCH NEXT 25 ROWS ONLY;
END;
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
Syntax:
Sequences
CREATE SEQUENCE [schema_name . ] sequence_name
[ AS [ built_in_integer_type | user-
defined_integer_type ] ]
[ START WITH <constant> ]
[ INCREMENT BY <constant> ]
[ { MINVALUE [ <constant> ] } | { NO MINVALUE }
]
[ { MAXVALUE [ <constant> ] } | { NO MAXVALUE }
]
[ CYCLE | { NO CYCLE } ]
[ { CACHE [ <constant> ] } | { NO CACHE } ]
[ ; ]
]
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• SQL:2008 Compliant
• Partial Syntax:
• New analytic functions
Extended support for Window Functions
OVER (
[ <PARTITION BY clause> ]
[ <ORDER BY clause> ]
[ <ROW or RANGE clause> ]
)
CUME_DIST LEAD FIRST_VALUE
PERCENTILE_CONT LAG PERCENTILE_DISC
LAST_VALUE PERCENT_RANK
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• Example
Extended support for Window Functions
(cont.)
SELECT
PS.Name AS SubcategoryName,
P.Name AS ProductName,
P.ListPrice,
FIRST_VALUE(P.Name) OVER (PARTITION BY
P.ProductSubcategoryID
ORDER BY P.ListPrice ASC) AS LeastExpensive
FROM Production.Product P
JOIN Production.ProductSubcategory PS
ON P.ProductSubcategoryID = PS.ProductSubcategoryID
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• Conversion functions
– PARSE
– TRY_CONVERT
– TRY_PARSE
• Date and time functions
– DATEFROMPARTS
– DATETIME2FROMPARTS
– DATETIMEFROMPARTS
– DATETIMEOFFSETFROMPARTS
– EOMONTH
– SMALLDATETIMEFROMPARTS
– TIMEFROMPARTS
New Functions
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• Logical functions
– CHOOSE
– IIF
• String functions
– CONCAT
– FORMAT
New Functions (cont.)
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
Syntax
THROW
THROW [ { error_number |
@local_variable },
{ message | @local_variable
},
{ state | @local_variable } ]
[ ; ]
itcampro@ itcamp13# Premium conference on Microsoft technologies
NEXT STEPS
Section 5
itcampro@ itcamp13# Premium conference on Microsoft technologies
Architecture &
Best Practices
• Read about Hekaton
• SQL Server 2012 Update for Developers
Training Workshop http://bit.ly/sql2012ro
• ROSQL http://sqlserver.ro
Next Steps
itcampro@ itcamp13# Premium conference on Microsoft technologies
Q & A
itcampro@ itcamp13# Premium conference on Microsoft technologies
THANK YOU!

More Related Content

PPTX
Introduction to database & sql
PDF
Sq lite module6
DOC
Dbms lab Manual
PPTX
SQL for interview
PPTX
Chapter 1 introduction to sql server
PDF
Database Systems - Introduction to SQL (Chapter 3/1)
PDF
Sql a practical introduction
PPTX
Physical Design and Development
Introduction to database & sql
Sq lite module6
Dbms lab Manual
SQL for interview
Chapter 1 introduction to sql server
Database Systems - Introduction to SQL (Chapter 3/1)
Sql a practical introduction
Physical Design and Development

What's hot (20)

PPTX
Structured Query Language (SQL)
PDF
Oracle advanced queuing
ODP
Ms sql-server
PPT
MySQL and its basic commands
PDF
Sql 2009
PDF
Sq lite module7
PPTX
Intro to T-SQL - 1st session
PPT
MYSQL.ppt
PPTX
SQL Server Learning Drive
PPTX
DDL(Data defination Language ) Using Oracle
PPTX
Sql - Structured Query Language
PPT
Fg d
PPTX
PDF
Oracle SQL Part1
PPTX
Database Basics Theory
PPTX
PPTX
Getting Started with MySQL II
PPTX
Physical Design and Development
PPTX
Introduction to database
Structured Query Language (SQL)
Oracle advanced queuing
Ms sql-server
MySQL and its basic commands
Sql 2009
Sq lite module7
Intro to T-SQL - 1st session
MYSQL.ppt
SQL Server Learning Drive
DDL(Data defination Language ) Using Oracle
Sql - Structured Query Language
Fg d
Oracle SQL Part1
Database Basics Theory
Getting Started with MySQL II
Physical Design and Development
Introduction to database
Ad

Viewers also liked (10)

PPTX
T sql語法之 cte 20140214
PPTX
Mastering T-SQL Window Functions
PPTX
Data twisting
PDF
Window functions with SQL Server 2016
PPT
Sql server ___________session 2(sql 2008)
PPTX
T-SQL: Pivot, Unpivot, Except, Intersect
PPTX
Exploring Advanced SQL Techniques Using Analytic Functions
PPTX
T-SQL Overview
PPTX
Introduction to SQL
PPT
Sql ppt
T sql語法之 cte 20140214
Mastering T-SQL Window Functions
Data twisting
Window functions with SQL Server 2016
Sql server ___________session 2(sql 2008)
T-SQL: Pivot, Unpivot, Except, Intersect
Exploring Advanced SQL Techniques Using Analytic Functions
T-SQL Overview
Introduction to SQL
Sql ppt
Ad

Similar to ITCamp 2013 - Cristian Lefter - Transact-SQL from 0 to SQL Server 2012 (20)

PPTX
Sql good practices
PDF
SQL Server 2008 Highlights
PPTX
SQL Server Workshop for Developers - Visual Studio Live! NY 2012
PPT
Application development using Microsoft SQL Server 2000
PPTX
SQL Server 2012 Best Practices
PDF
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
PDF
MIS5101 WK10 Outcome Measures
PPTX
Microsoft SQL Server 2008
PDF
FREE Sql Server syllabus
PPT
SQL Server 2008 Overview
PPT
What's New for Developers in SQL Server 2008?
PPTX
SQL Server Worst Practices - EN
PPT
Presentation1
PPT
Sql server T-sql basics ppt-3
PPT
Introduction to Threading in .Net
PPTX
Sql server infernals
PDF
Sql Server2008
PPTX
6232 b 01
PPT
Chap 7
Sql good practices
SQL Server 2008 Highlights
SQL Server Workshop for Developers - Visual Studio Live! NY 2012
Application development using Microsoft SQL Server 2000
SQL Server 2012 Best Practices
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
MIS5101 WK10 Outcome Measures
Microsoft SQL Server 2008
FREE Sql Server syllabus
SQL Server 2008 Overview
What's New for Developers in SQL Server 2008?
SQL Server Worst Practices - EN
Presentation1
Sql server T-sql basics ppt-3
Introduction to Threading in .Net
Sql server infernals
Sql Server2008
6232 b 01
Chap 7

More from ITCamp (20)

PDF
ITCamp 2019 - Stacey M. Jenkins - Protecting your company's data - By psychol...
PDF
ITCamp 2019 - Silviu Niculita - Supercharge your AI efforts with the use of A...
PDF
ITCamp 2019 - Peter Leeson - Managing Skills
PPTX
ITCamp 2019 - Mihai Tataran - Governing your Cloud Resources
PDF
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
PDF
ITCamp 2019 - Florin Coros - Implementing Clean Architecture
PPTX
ITCamp 2019 - Florin Loghiade - Azure Kubernetes in Production - Field notes...
PPTX
ITCamp 2019 - Florin Flestea - How 3rd Level support experience influenced m...
PPTX
ITCamp 2019 - Emil Craciun - RoboRestaurant of the future powered by serverle...
PPTX
ITCamp 2019 - Eldert Grootenboer - Cloud Architecture Recipes for The Enterprise
PPTX
ITCamp 2019 - Cristiana Fernbach - Blockchain Legal Trends
PPTX
ITCamp 2019 - Andy Cross - Machine Learning with ML.NET and Azure Data Lake
PPTX
ITCamp 2019 - Andy Cross - Business Outcomes from AI
PDF
ITCamp 2019 - Andrea Saltarello - Modernise your app. The Cloud Story
PDF
ITCamp 2019 - Andrea Saltarello - Implementing bots and Alexa skills using Az...
PPTX
ITCamp 2019 - Alex Mang - I'm Confused Should I Orchestrate my Containers on ...
PPTX
ITCamp 2019 - Alex Mang - How Far Can Serverless Actually Go Now
PDF
ITCamp 2019 - Peter Leeson - Vitruvian Quality
PDF
ITCamp 2018 - Ciprian Sorlea - Million Dollars Hello World Application
PDF
ITCamp 2018 - Ciprian Sorlea - Enterprise Architectures with TypeScript And F...
ITCamp 2019 - Stacey M. Jenkins - Protecting your company's data - By psychol...
ITCamp 2019 - Silviu Niculita - Supercharge your AI efforts with the use of A...
ITCamp 2019 - Peter Leeson - Managing Skills
ITCamp 2019 - Mihai Tataran - Governing your Cloud Resources
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp 2019 - Florin Coros - Implementing Clean Architecture
ITCamp 2019 - Florin Loghiade - Azure Kubernetes in Production - Field notes...
ITCamp 2019 - Florin Flestea - How 3rd Level support experience influenced m...
ITCamp 2019 - Emil Craciun - RoboRestaurant of the future powered by serverle...
ITCamp 2019 - Eldert Grootenboer - Cloud Architecture Recipes for The Enterprise
ITCamp 2019 - Cristiana Fernbach - Blockchain Legal Trends
ITCamp 2019 - Andy Cross - Machine Learning with ML.NET and Azure Data Lake
ITCamp 2019 - Andy Cross - Business Outcomes from AI
ITCamp 2019 - Andrea Saltarello - Modernise your app. The Cloud Story
ITCamp 2019 - Andrea Saltarello - Implementing bots and Alexa skills using Az...
ITCamp 2019 - Alex Mang - I'm Confused Should I Orchestrate my Containers on ...
ITCamp 2019 - Alex Mang - How Far Can Serverless Actually Go Now
ITCamp 2019 - Peter Leeson - Vitruvian Quality
ITCamp 2018 - Ciprian Sorlea - Million Dollars Hello World Application
ITCamp 2018 - Ciprian Sorlea - Enterprise Architectures with TypeScript And F...

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Empathic Computing: Creating Shared Understanding
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
cuic standard and advanced reporting.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Cloud computing and distributed systems.
PDF
Electronic commerce courselecture one. Pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Programs and apps: productivity, graphics, security and other tools
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation_ Review paper, used for researhc scholars
Empathic Computing: Creating Shared Understanding
20250228 LYD VKU AI Blended-Learning.pptx
A Presentation on Artificial Intelligence
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
cuic standard and advanced reporting.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Cloud computing and distributed systems.
Electronic commerce courselecture one. Pdf
Network Security Unit 5.pdf for BCA BBA.
Mobile App Security Testing_ A Comprehensive Guide.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Programs and apps: productivity, graphics, security and other tools
The AUB Centre for AI in Media Proposal.docx
Building Integrated photovoltaic BIPV_UPV.pdf
Machine learning based COVID-19 study performance prediction
gpt5_lecture_notes_comprehensive_20250812015547.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Per capita expenditure prediction using model stacking based on satellite ima...

ITCamp 2013 - Cristian Lefter - Transact-SQL from 0 to SQL Server 2012

  • 1. itcampro@ itcamp13# Premium conference on Microsoft technologies Transact-SQL from 0 to SQL Server 2012 Cristian Lefter SQL Server MVP http://about.me/CristianLefter
  • 2. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best PracticesHuge thanks to our sponsors!
  • 3. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • Introduction • SQL Server 20XX • Next Steps Agenda
  • 4. itcampro@ itcamp13# Premium conference on Microsoft technologies INSTEAD OF AN INTRODUCTION Section 1
  • 5. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • Initially developed at IBM by Donald D. Chamberlin and Raymond F. Boyce in the early 1970s under the name of SEQUEL (Structured English Query Language) • Designed to manipulate and retrieve data stored in IBM's original quasi-relational database management system, System R • Based on Edgar F. Codd's relational model, described in his 1970 paper "A Relational Model of Data for Large Shared Data Banks” • Was renamed SQL because "SEQUEL" was a trademark of an UK-based aircraft company. • SQL becomes a standard of the American National Standards Institute (ANSI) in 1986 and for International Organization for Standards (ISO) in 1987 SQL - history
  • 6. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices Version Year Release Name Codename 1.0 (OS/2) 1989 SQL Server 1.0 (16 bit) - 1.1 (OS/2) 1991 SQL Server 1.1 (16 bit) - 4.21 (WinNT) 1993 SQL Server 4.21 SQLNT 6.0 1995 SQL Server 6.0 SQL95 6.5 1996 SQL Server 6.5 Hydra 7.0 1998 SQL Server 7.0 Sphinx - 1999 SQL Server 7.0 OLAP Tools Plato mania Microsoft SQL Server History
  • 7. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices Version Year Release Name Codename 8.0 2000 SQL Server 2000 Shiloh 8.0 2003 SQL Server 2000 64-bit Edition Liberty 9.0 2005 SQL Server 2005 Yukon 10.0 2008 SQL Server 2008 Katmai 10.25 2010 SQL Azure DB CloudDatabase 10.5 2010 SQL Server 2008 R2 Kilimanjaro (aka KJ) 11.0 2012 SQL Server 2012 Denali Microsoft SQL Server History (cont.)
  • 8. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best PracticesVersion 1.0
  • 9. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best PracticesVersion 1.1 on OS/2 – SQL Admin Facility
  • 10. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices What is a database? A collection of objects known as tables. For the OS, a database is simply a file. What is a table? A table is a set of data elements (values) that is organized using a model of vertical columns (which are identified by their name) and horizontal rows. Database related terms
  • 11. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • Are these familiar to you? – SELECT / INSERT / UPDATE / DELETE • How about these? – GROUP BY, PROCEDURE, FUNCTION, TRIGGER Where Do We Start From?
  • 12. itcampro@ itcamp13# Premium conference on Microsoft technologies SQL SERVER 2000 Section 2
  • 13. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • XML support - FOR XML clause • User-Defined Functions • Indexed Views • INSTEAD OF and AFTER triggers New in SQL Server 2000
  • 14. itcampro@ itcamp13# Premium conference on Microsoft technologies SQL SERVER 2005 Section 2
  • 15. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices Syntax: Common Table Expressions (CTE) WITH <common_table_expression> [ ,...n ] <common_table_expression>::= expression_name [ ( column_name [ ,...n ] )] AS ( CTE_query_definition )
  • 16. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices Syntax: OUTPUT clause OUTPUT <dml_select_list> INTO { @table_variable | output_table } [ ( column_list ) ] [ OUTPUT <dml_select_list> ]
  • 17. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • CROSS APPLY • OUTER APPLY Syntax: APPLY operator FROM left_table_source {OUTER | CROSS} APPLY right_table_source
  • 18. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices Partial Syntax: PIVOT and UNPIVOT operators SELECT * FROM table_source PIVOT (aggregate_function ( value_column ) FOR pivot_column IN ( <column_list> ) ) table_alias
  • 19. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • CREATE LOGIN, • ALTER LOGIN • DROP LOGIN • CREATE USER • ALTER USER • DROP USER Security Statements
  • 20. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices Syntax: Error Handling BEGIN TRY { sql_statement | statement_block } END TRY BEGIN CATCH { sql_statement | statement_block } END CATCH [ ; ]
  • 21. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • RANK • DENSE_RANK • NTILE • ROW_NUMBER Ranking Functions
  • 22. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • .NET Integration • XML support (xml data type, XQUERY support, XML Data Manipulation Language, XML Schemas support) • VARCHAR(MAX), VARBINARY(MAX) • Execution context – EXECUTE AS • Schemas Other things to mention
  • 23. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • Full-text Search DDL – CREATE FULLTEXT CATALOG – CREATE FULLTEXT INDEX • DDL Triggers • Event Notifications • Service Broker – SEND – RECEIVE • Partitioning – CREATE PARTITION FUNCTION – CREATE PARTITION SCHEME – CREATE TABLE table_name ON partition_scheme_name (column_name) Other things to mention (cont.)
  • 24. itcampro@ itcamp13# Premium conference on Microsoft technologies SQL SERVER 2008 Section 3
  • 25. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • Row Constructors • One statement variable declaration/assignment • Compound assignment operators T-SQL delighters
  • 26. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices Syntax: INSERT over DML OUTPUT <dml_select_list> INTO{ @table_variable|output_table} [(column_list)]][OUTPUT<dml_select_list>] <dml_select_list> ::= { <column_name> | scalar_expression } [ [AS] column_alias_identifier ][ ,...n ] <column_name> ::={DELETED|INSERTED| from_table_name}.{*|column_name}|$ACTION
  • 27. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices Example of usage: Table-valued parameters CREATE TABLE StockTransactions(TransactionID INT PRIMARY KEY IDENTITY(1,1),StockSymbol VARCHAR(64),Qty INT); GO CREATE TYPE TransactionType AS TABLE (StockSymbol VARCHAR(64), Qty INT); GO CREATE PROCEDURE usp_InsertTransaction @TVP TransactionType READONLY AS BEGIN SET NOCOUNT ON INSERT INTO StockTransactions(StockSymbol,Qty) SELECT StockSymbol,Qty FROM @TVP; END; GO
  • 28. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices Partial syntax: MERGE statement MERGE [INTO] target_table USING <table_source> ON <search_condition> [WHEN MATCHED [AND <search_condition>] THEN <merge_matched>] [WHEN [TARGET] NOT MATCHED [AND <search_condition>] THEN <merge_not_matched>] [WHEN SOURCE NOT MATCHED [AND <search_condition>] THEN <merge_matched>] <output_clause>;
  • 29. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • DATE • TIME • DATETIME2 • DATETIMEOFFSET Date and Time Data Types
  • 30. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • Sparse Columns and Column Sets • HierarchyID data type • GROUP BY Enhancements • Resource Governor • Transparent Data Encryption • SQL Server Audit • Extended Events • Data Compression • Backup Compression Other things to mention
  • 31. itcampro@ itcamp13# Premium conference on Microsoft technologies SQL SERVER 2008 R2 Section 4
  • 32. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • Nothing major for T-SQL except UNICODE compression SQL Server 2008 R2
  • 33. itcampro@ itcamp13# Premium conference on Microsoft technologies SQL SERVER 2012 Section 4
  • 34. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best PracticesQuery Pagination Syntax: Example: OFFSET <offset_value> ROW|ROWS FETCH FIRST|NEXT <fetch_value> ROW|ROWS [ONLY] SELECT ProductID, Name,Color, Size FROM Production.Product ORDER BY Color,ProductID ASC OFFSET 100 ROWS FETCH NEXT 25 ROWS ONLY; END;
  • 35. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices Syntax: Sequences CREATE SEQUENCE [schema_name . ] sequence_name [ AS [ built_in_integer_type | user- defined_integer_type ] ] [ START WITH <constant> ] [ INCREMENT BY <constant> ] [ { MINVALUE [ <constant> ] } | { NO MINVALUE } ] [ { MAXVALUE [ <constant> ] } | { NO MAXVALUE } ] [ CYCLE | { NO CYCLE } ] [ { CACHE [ <constant> ] } | { NO CACHE } ] [ ; ] ]
  • 36. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • SQL:2008 Compliant • Partial Syntax: • New analytic functions Extended support for Window Functions OVER ( [ <PARTITION BY clause> ] [ <ORDER BY clause> ] [ <ROW or RANGE clause> ] ) CUME_DIST LEAD FIRST_VALUE PERCENTILE_CONT LAG PERCENTILE_DISC LAST_VALUE PERCENT_RANK
  • 37. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • Example Extended support for Window Functions (cont.) SELECT PS.Name AS SubcategoryName, P.Name AS ProductName, P.ListPrice, FIRST_VALUE(P.Name) OVER (PARTITION BY P.ProductSubcategoryID ORDER BY P.ListPrice ASC) AS LeastExpensive FROM Production.Product P JOIN Production.ProductSubcategory PS ON P.ProductSubcategoryID = PS.ProductSubcategoryID
  • 38. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • Conversion functions – PARSE – TRY_CONVERT – TRY_PARSE • Date and time functions – DATEFROMPARTS – DATETIME2FROMPARTS – DATETIMEFROMPARTS – DATETIMEOFFSETFROMPARTS – EOMONTH – SMALLDATETIMEFROMPARTS – TIMEFROMPARTS New Functions
  • 39. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • Logical functions – CHOOSE – IIF • String functions – CONCAT – FORMAT New Functions (cont.)
  • 40. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices Syntax THROW THROW [ { error_number | @local_variable }, { message | @local_variable }, { state | @local_variable } ] [ ; ]
  • 41. itcampro@ itcamp13# Premium conference on Microsoft technologies NEXT STEPS Section 5
  • 42. itcampro@ itcamp13# Premium conference on Microsoft technologies Architecture & Best Practices • Read about Hekaton • SQL Server 2012 Update for Developers Training Workshop http://bit.ly/sql2012ro • ROSQL http://sqlserver.ro Next Steps
  • 43. itcampro@ itcamp13# Premium conference on Microsoft technologies Q & A
  • 44. itcampro@ itcamp13# Premium conference on Microsoft technologies THANK YOU!