SlideShare a Scribd company logo
1 of 15
Download to read offline
Digicomp Academy
SQL Day    n  Neue T-SQL Features
Ihr Kursleiter
n  Roland Strauss
n  Kaufm. Lehre/Programmierer/Analytiker
n  Selbstständig seit 1984
n  SQL Server seit Version 4.2 (1993)
n  Kursleiter SQL Server seit 1994
Neue Befehle
n  WITH RESULT SETS
n  OFFSET AND FETCH
n  THROW in Error handling
n  SEQUENCE
n  Get Metadata of Resultset
EXEC Proc WITH ...
[ WITH <execute_option> [ ,…n ] ]

<execute_option>::=
{
               RECOMPILE
               | { RESULT SETS UNDEFINED }
               | { RESULT SETS NONE }
               | { RESULT SETS ( <result_sets_definition> [,…n] ) }
}

<result_sets_definition> ::=
{
                (
                                    { column_name
                                      data_type
                                    [ COLLATE collation_name ]
                                    [ NULL | NOT NULL ] }
                                    [,…n ]
                 )
                 | AS OBJECT
                                 [ db_name . [ schema_name ] . | schema_name . ]
                                 {table_name | view_name | table_valued_function_name }
                 | AS TYPE [ schema_name.]table_type_name
                 | AS FOR XML
}
WITH RESULT SETS
CREATE	
  PROCEDURE	
  Denali_WithResultSet	
  AS	
  
BEGIN	
  	
  
	
  	
  SELECT	
  1	
  as	
  No,’Tsql’	
  Type,	
  ‘WithResultSet’	
  AS	
  Feature	
  UNION	
  ALL	
  
	
  	
  SELECT	
  2	
  as	
  No,’Tsql’	
  Type,	
  ‘Throw’	
  AS	
  Feature	
  UNION	
  ALL	
  
	
  	
  SELECT	
  3	
  as	
  No,’Tsql’	
  Type,	
  ‘Offset’	
  AS	
  Feature	
  UNION	
  ALL	
  
	
  	
  SELECT	
  4	
  as	
  No,’Tsql’	
  Type,	
  ‘Sequence’	
  AS	
  Feature	
  	
  
END	
  
GO	
  
EXEC	
  Denali_WithResultSet	
  	
  
WITH	
  RESULT	
  SETS	
  
(	
  
	
  	
  (	
       	
  No       	
          	
  int,	
  
                  	
  FeatureType          	
  varchar(50),	
  
                  	
  FeatureName	
        	
  varchar(50)	
  
	
  	
  )	
  	
  
)	
  	
  
OFFSET and FETCH
	
  ORDER	
  BY	
  order_by_expression	
  
	
  	
  	
  	
  [	
  COLLATE	
  collation_name	
  ]	
  	
  
	
  	
  	
  	
  [	
  ASC	
  |	
  DESC	
  ]	
  	
  
	
  	
  	
  	
  [	
  ,...n	
  ]	
  	
  
[	
  <offset_fetch>	
  ]	
  
	
  
	
  
<offset_fetch>	
  ::=	
  
{	
  	
  
	
  	
  	
  	
  OFFSET	
  {	
  integer_constant	
  |	
  offset_row_count_expression	
  }	
  {	
  ROW	
  |	
  ROWS	
  }	
  
	
  	
  	
  	
  [	
  
	
  	
  	
  	
  	
  	
  FETCH	
  {	
  FIRST	
  |	
  NEXT	
  }	
  {integer_constant	
  |	
  fetch_row_count_expression	
  }	
  
{	
  ROW	
  |	
  ROWS	
  }	
  ONLY	
  
	
  	
  	
  	
  ]	
  
}	
  
OFFSET and FETCH
SELECT	
  ProductID,	
  Name	
  	
  
FROM	
  Production.Product	
  
ORDER	
  BY	
  NAME	
  	
  
OFFSET	
  10	
  ROWS	
  
FETCH	
  NEXT	
  5	
  ROWS	
  ONLY	
  
THROW
n  Bisher signalisierte man einen Fehler mit RAISERROR	
  (nnnnn,	
  16,	
  
    1)	
  
n  Fehlermeldung musste in sys.messages existieren
n  Fehler konnte nicht im CATCH-Block wiederholt werden
n  Mit Throw kann eine beliebige Fehlernummer verwendet werden
n  Ausführung von Throw ohne Parameter im CATCH Block wiederholt
    die auslösende Fehlermeldung
THROW

THROW [ { error_number | @local_variable },
     { message | @local_variable },
  { state | @local_variable }
][;]
THROW
BEGIN	
  TRY	
  
          	
  BEGIN	
  TRANSACTION	
  -­‐-­‐	
  Start	
  the	
  transaction	
  
          	
  -­‐-­‐	
  Delete	
  the	
  Customer	
  
          	
  DELETE	
  FROM	
  Customers	
  
          	
  WHERE	
  EmployeeID	
  =	
  ‘CACTU’	
  
	
  
          	
  -­‐-­‐	
  Commit	
  the	
  change	
  
          	
  COMMIT	
  TRANSACTION	
  
END	
  TRY	
  
BEGIN	
  CATCH	
  
          	
  -­‐-­‐	
  There	
  is	
  an	
  error	
  
          	
  ROLLBACK	
  TRANSACTION	
  
          	
  -­‐-­‐	
  Re	
  throw	
  the	
  exception	
  
          	
  THROW	
  
END	
  CATCH	
  
SEQUENCE
n  Globale IDENTITY
n  Steht nicht unter Transaktionskontrolle
	
  
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	
  }	
  ]	
  
	
  	
  	
  	
  [	
  ;	
  ]	
  
SEQUENCE
CREATE	
  SEQUENCE	
  dbo.Seq	
  AS	
  INT	
  
START	
  WITH	
  1	
  
INCREMENT	
  BY	
  1;	
  
	
  
CREATE	
  TABLE	
  dbo.Examp1	
  
(	
  
	
  	
  Seq	
  INT	
  NOT	
  NULL,	
  
	
  	
  Name	
  VARCHAR(50)	
  NOT	
  NULL	
  
);	
  

INSERT	
  INTO	
  dbo.Examp1(Seq,	
  Name)	
  VALUES(NEXT	
  VALUE	
  FOR	
  
dbo.Seq,	
  ‘Tom’);	
  
	
  
	
  
Get Metadata of ResultSets

n  Erzeugt detaillierte Beschreibung des Result Sets


sp_describe_first_result_set	
  	
  
@tsql	
  =	
  N’SELECT	
  *	
  FROM	
  customers’	
  	
  
Andere Erweiterungen
n  Weiter auf MSDN
n  http://msdn.microsoft.com/en-us/library/cc645577.aspx
Kurse Digicomp
MOC	
  10774:	
  Wri-ng	
  Queries	
  with	
  Microso9	
  SQL	
  Server	
  
2012	
  Transact-­‐SQL	
  (5	
  Tage)	
  
	
  

More Related Content

What's hot

T sql denali code Day of .Net
T sql denali code Day of .NetT sql denali code Day of .Net
T sql denali code Day of .Net
KathiK58
 
Functions oracle (pl/sql)
Functions oracle (pl/sql)Functions oracle (pl/sql)
Functions oracle (pl/sql)
harman kaur
 
Les01-Oracle
Les01-OracleLes01-Oracle
Les01-Oracle
suman1248
 

What's hot (19)

Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
 
The Ring programming language version 1.2 book - Part 11 of 84
The Ring programming language version 1.2 book - Part 11 of 84The Ring programming language version 1.2 book - Part 11 of 84
The Ring programming language version 1.2 book - Part 11 of 84
 
Dbms file
Dbms fileDbms file
Dbms file
 
The Ring programming language version 1.7 book - Part 25 of 196
The Ring programming language version 1.7 book - Part 25 of 196The Ring programming language version 1.7 book - Part 25 of 196
The Ring programming language version 1.7 book - Part 25 of 196
 
Les06 Subqueries
Les06 SubqueriesLes06 Subqueries
Les06 Subqueries
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
T sql denali code Day of .Net
T sql denali code Day of .NetT sql denali code Day of .Net
T sql denali code Day of .Net
 
Oracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guideOracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guide
 
Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sql
 
Les12 creating views
Les12 creating viewsLes12 creating views
Les12 creating views
 
Functions oracle (pl/sql)
Functions oracle (pl/sql)Functions oracle (pl/sql)
Functions oracle (pl/sql)
 
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
 
Oracle - Program with PL/SQL - Lession 07
Oracle - Program with PL/SQL - Lession 07Oracle - Program with PL/SQL - Lession 07
Oracle - Program with PL/SQL - Lession 07
 
Les01-Oracle
Les01-OracleLes01-Oracle
Les01-Oracle
 
MySQL partitions tutorial
MySQL partitions tutorialMySQL partitions tutorial
MySQL partitions tutorial
 
New text document
New text documentNew text document
New text document
 
The Ring programming language version 1.9 book - Part 42 of 210
The Ring programming language version 1.9 book - Part 42 of 210The Ring programming language version 1.9 book - Part 42 of 210
The Ring programming language version 1.9 book - Part 42 of 210
 
A Tour to MySQL Commands
A Tour to MySQL CommandsA Tour to MySQL Commands
A Tour to MySQL Commands
 
PL/SQL
PL/SQLPL/SQL
PL/SQL
 

Viewers also liked

Effectiveness of Simulated Experience in teaching Social Skills to children w...
Effectiveness of Simulated Experience in teaching Social Skills to children w...Effectiveness of Simulated Experience in teaching Social Skills to children w...
Effectiveness of Simulated Experience in teaching Social Skills to children w...
Amanda Goh
 
Ahmad Abu Ghoush CV's 02042015_1_
Ahmad Abu Ghoush CV's 02042015_1_Ahmad Abu Ghoush CV's 02042015_1_
Ahmad Abu Ghoush CV's 02042015_1_
ahmad abu ghoush
 
Ryan Wooden's Resume
Ryan Wooden's ResumeRyan Wooden's Resume
Ryan Wooden's Resume
Ryan Wooden
 

Viewers also liked (20)

Lemon oil test
Lemon oil testLemon oil test
Lemon oil test
 
SQL SoloLearn
SQL SoloLearnSQL SoloLearn
SQL SoloLearn
 
Math (Summer 2016) CHD 120
Math (Summer 2016) CHD 120Math (Summer 2016) CHD 120
Math (Summer 2016) CHD 120
 
Good Enough Prototype (Ivan Pashko Product Stream)
Good Enough Prototype (Ivan Pashko Product Stream)Good Enough Prototype (Ivan Pashko Product Stream)
Good Enough Prototype (Ivan Pashko Product Stream)
 
Tl first group brochure
Tl first group brochureTl first group brochure
Tl first group brochure
 
Effectiveness of Simulated Experience in teaching Social Skills to children w...
Effectiveness of Simulated Experience in teaching Social Skills to children w...Effectiveness of Simulated Experience in teaching Social Skills to children w...
Effectiveness of Simulated Experience in teaching Social Skills to children w...
 
14 albrieu&amp;baruzzi 2016 xviica vyt comparaciónnormasdºgº
14 albrieu&amp;baruzzi 2016 xviica vyt comparaciónnormasdºgº14 albrieu&amp;baruzzi 2016 xviica vyt comparaciónnormasdºgº
14 albrieu&amp;baruzzi 2016 xviica vyt comparaciónnormasdºgº
 
LINQ
LINQLINQ
LINQ
 
Art
ArtArt
Art
 
Ahmad Abu Ghoush CV's 02042015_1_
Ahmad Abu Ghoush CV's 02042015_1_Ahmad Abu Ghoush CV's 02042015_1_
Ahmad Abu Ghoush CV's 02042015_1_
 
Ryan Wooden's Resume
Ryan Wooden's ResumeRyan Wooden's Resume
Ryan Wooden's Resume
 
Surih bentuk
Surih bentukSurih bentuk
Surih bentuk
 
One single motion presentation
One single motion presentationOne single motion presentation
One single motion presentation
 
The future of engineering education
The future of engineering educationThe future of engineering education
The future of engineering education
 
Intro To TSQL - Unit 5
Intro To TSQL - Unit 5Intro To TSQL - Unit 5
Intro To TSQL - Unit 5
 
Fascinate with SQL SSIS Parallel processing
Fascinate with SQL SSIS Parallel processing Fascinate with SQL SSIS Parallel processing
Fascinate with SQL SSIS Parallel processing
 
SSIS coding conventions, best practices, tips and programming guidelines for ...
SSIS coding conventions, best practices, tips and programming guidelines for ...SSIS coding conventions, best practices, tips and programming guidelines for ...
SSIS coding conventions, best practices, tips and programming guidelines for ...
 
Концептуальні засади реформування сфери інтелектуальної власності та її роль...
Концептуальні засади реформування  сфери інтелектуальної власності та її роль...Концептуальні засади реформування  сфери інтелектуальної власності та її роль...
Концептуальні засади реформування сфери інтелектуальної власності та її роль...
 
Don’t Ask for Permission, Ask for Forgiveness (Thomas Schoerner Product Stream)
Don’t Ask for Permission, Ask for Forgiveness (Thomas Schoerner Product Stream)Don’t Ask for Permission, Ask for Forgiveness (Thomas Schoerner Product Stream)
Don’t Ask for Permission, Ask for Forgiveness (Thomas Schoerner Product Stream)
 
DAX and Power BI Training - 002 DAX Level 1 - 3
DAX and Power BI Training - 002 DAX Level 1 - 3DAX and Power BI Training - 002 DAX Level 1 - 3
DAX and Power BI Training - 002 DAX Level 1 - 3
 

Similar to New tsql features

Developers' New features of Sql server express 2012
Developers' New features of Sql server express 2012Developers' New features of Sql server express 2012
Developers' New features of Sql server express 2012
Ziaur Rahman
 
СУБД осень 2012 Лекция 3
СУБД осень 2012 Лекция 3СУБД осень 2012 Лекция 3
СУБД осень 2012 Лекция 3
Technopark
 
7a advanced tsql
7a   advanced tsql7a   advanced tsql
7a advanced tsql
Nauman R
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
Reka
 
C-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression CalculatorC-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression Calculator
Neeraj Kaushik
 
Exploring collections with example
Exploring collections with exampleExploring collections with example
Exploring collections with example
pranav kumar verma
 

Similar to New tsql features (20)

Introducción rápida a SQL
Introducción rápida a SQLIntroducción rápida a SQL
Introducción rápida a SQL
 
Sql
SqlSql
Sql
 
Developers' New features of Sql server express 2012
Developers' New features of Sql server express 2012Developers' New features of Sql server express 2012
Developers' New features of Sql server express 2012
 
СУБД осень 2012 Лекция 3
СУБД осень 2012 Лекция 3СУБД осень 2012 Лекция 3
СУБД осень 2012 Лекция 3
 
Oracle APEX Cheat Sheet
Oracle APEX Cheat SheetOracle APEX Cheat Sheet
Oracle APEX Cheat Sheet
 
SQL introduction
SQL introductionSQL introduction
SQL introduction
 
7a advanced tsql
7a   advanced tsql7a   advanced tsql
7a advanced tsql
 
MySQL Pro
MySQL ProMySQL Pro
MySQL Pro
 
Mysql1
Mysql1Mysql1
Mysql1
 
Oracle
OracleOracle
Oracle
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
C-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression CalculatorC-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression Calculator
 
Procedures and triggers in SQL
Procedures and triggers in SQLProcedures and triggers in SQL
Procedures and triggers in SQL
 
Les09
Les09Les09
Les09
 
MySQL-commands.pdf
MySQL-commands.pdfMySQL-commands.pdf
MySQL-commands.pdf
 
Exploring collections with example
Exploring collections with exampleExploring collections with example
Exploring collections with example
 
Array,MULTI ARRAY, IN C
Array,MULTI ARRAY, IN CArray,MULTI ARRAY, IN C
Array,MULTI ARRAY, IN C
 
Database queries
Database queriesDatabase queries
Database queries
 
Module03
Module03Module03
Module03
 

More from Digicomp Academy AG

Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
Digicomp Academy AG
 

More from Digicomp Academy AG (20)

Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
 
Swiss IPv6 Council – Case Study - Deployment von IPv6 in einer Container Plat...
Swiss IPv6 Council – Case Study - Deployment von IPv6 in einer Container Plat...Swiss IPv6 Council – Case Study - Deployment von IPv6 in einer Container Plat...
Swiss IPv6 Council – Case Study - Deployment von IPv6 in einer Container Plat...
 
Innovation durch kollaboration gennex 2018
Innovation durch kollaboration gennex 2018Innovation durch kollaboration gennex 2018
Innovation durch kollaboration gennex 2018
 
Roger basler meetup_digitale-geschaeftsmodelle-entwickeln_handout
Roger basler meetup_digitale-geschaeftsmodelle-entwickeln_handoutRoger basler meetup_digitale-geschaeftsmodelle-entwickeln_handout
Roger basler meetup_digitale-geschaeftsmodelle-entwickeln_handout
 
Roger basler meetup_21082018_work-smarter-not-harder_handout
Roger basler meetup_21082018_work-smarter-not-harder_handoutRoger basler meetup_21082018_work-smarter-not-harder_handout
Roger basler meetup_21082018_work-smarter-not-harder_handout
 
Xing expertendialog zu nudge unit x
Xing expertendialog zu nudge unit xXing expertendialog zu nudge unit x
Xing expertendialog zu nudge unit x
 
Responsive Organisation auf Basis der Holacracy – nur ein Hype oder die Zukunft?
Responsive Organisation auf Basis der Holacracy – nur ein Hype oder die Zukunft?Responsive Organisation auf Basis der Holacracy – nur ein Hype oder die Zukunft?
Responsive Organisation auf Basis der Holacracy – nur ein Hype oder die Zukunft?
 
IPv6 Security Talk mit Joe Klein
IPv6 Security Talk mit Joe KleinIPv6 Security Talk mit Joe Klein
IPv6 Security Talk mit Joe Klein
 
Agiles Management - Wie geht das?
Agiles Management - Wie geht das?Agiles Management - Wie geht das?
Agiles Management - Wie geht das?
 
Gewinnen Sie Menschen und Ziele - Referat von Andi Odermatt
Gewinnen Sie Menschen und Ziele - Referat von Andi OdermattGewinnen Sie Menschen und Ziele - Referat von Andi Odermatt
Gewinnen Sie Menschen und Ziele - Referat von Andi Odermatt
 
Querdenken mit Kreativitätsmethoden – XING Expertendialog
Querdenken mit Kreativitätsmethoden – XING ExpertendialogQuerdenken mit Kreativitätsmethoden – XING Expertendialog
Querdenken mit Kreativitätsmethoden – XING Expertendialog
 
Xing LearningZ: Digitale Geschäftsmodelle entwickeln
Xing LearningZ: Digitale Geschäftsmodelle entwickelnXing LearningZ: Digitale Geschäftsmodelle entwickeln
Xing LearningZ: Digitale Geschäftsmodelle entwickeln
 
Swiss IPv6 Council: The Cisco-Journey to an IPv6-only Building
Swiss IPv6 Council: The Cisco-Journey to an IPv6-only BuildingSwiss IPv6 Council: The Cisco-Journey to an IPv6-only Building
Swiss IPv6 Council: The Cisco-Journey to an IPv6-only Building
 
UX – Schlüssel zum Erfolg im Digital Business
UX – Schlüssel zum Erfolg im Digital BusinessUX – Schlüssel zum Erfolg im Digital Business
UX – Schlüssel zum Erfolg im Digital Business
 
Minenfeld IPv6
Minenfeld IPv6Minenfeld IPv6
Minenfeld IPv6
 
Was ist design thinking
Was ist design thinkingWas ist design thinking
Was ist design thinking
 
Die IPv6 Journey der ETH Zürich
Die IPv6 Journey der ETH Zürich Die IPv6 Journey der ETH Zürich
Die IPv6 Journey der ETH Zürich
 
Xing LearningZ: Die 10 + 1 Trends im (E-)Commerce
Xing LearningZ: Die 10 + 1 Trends im (E-)CommerceXing LearningZ: Die 10 + 1 Trends im (E-)Commerce
Xing LearningZ: Die 10 + 1 Trends im (E-)Commerce
 
Zahlen Battle: klassische werbung vs.online-werbung-somexcloud
Zahlen Battle: klassische werbung vs.online-werbung-somexcloudZahlen Battle: klassische werbung vs.online-werbung-somexcloud
Zahlen Battle: klassische werbung vs.online-werbung-somexcloud
 
General data protection regulation-slides
General data protection regulation-slidesGeneral data protection regulation-slides
General data protection regulation-slides
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

New tsql features

  • 1. Digicomp Academy SQL Day n  Neue T-SQL Features
  • 2. Ihr Kursleiter n  Roland Strauss n  Kaufm. Lehre/Programmierer/Analytiker n  Selbstständig seit 1984 n  SQL Server seit Version 4.2 (1993) n  Kursleiter SQL Server seit 1994
  • 3. Neue Befehle n  WITH RESULT SETS n  OFFSET AND FETCH n  THROW in Error handling n  SEQUENCE n  Get Metadata of Resultset
  • 4. EXEC Proc WITH ... [ WITH <execute_option> [ ,…n ] ] <execute_option>::= { RECOMPILE | { RESULT SETS UNDEFINED } | { RESULT SETS NONE } | { RESULT SETS ( <result_sets_definition> [,…n] ) } } <result_sets_definition> ::= { ( { column_name data_type [ COLLATE collation_name ] [ NULL | NOT NULL ] } [,…n ] ) | AS OBJECT [ db_name . [ schema_name ] . | schema_name . ] {table_name | view_name | table_valued_function_name } | AS TYPE [ schema_name.]table_type_name | AS FOR XML }
  • 5. WITH RESULT SETS CREATE  PROCEDURE  Denali_WithResultSet  AS   BEGIN        SELECT  1  as  No,’Tsql’  Type,  ‘WithResultSet’  AS  Feature  UNION  ALL      SELECT  2  as  No,’Tsql’  Type,  ‘Throw’  AS  Feature  UNION  ALL      SELECT  3  as  No,’Tsql’  Type,  ‘Offset’  AS  Feature  UNION  ALL      SELECT  4  as  No,’Tsql’  Type,  ‘Sequence’  AS  Feature     END   GO   EXEC  Denali_WithResultSet     WITH  RESULT  SETS   (      (    No    int,    FeatureType  varchar(50),    FeatureName    varchar(50)      )     )    
  • 6. OFFSET and FETCH  ORDER  BY  order_by_expression          [  COLLATE  collation_name  ]            [  ASC  |  DESC  ]            [  ,...n  ]     [  <offset_fetch>  ]       <offset_fetch>  ::=   {            OFFSET  {  integer_constant  |  offset_row_count_expression  }  {  ROW  |  ROWS  }          [              FETCH  {  FIRST  |  NEXT  }  {integer_constant  |  fetch_row_count_expression  }   {  ROW  |  ROWS  }  ONLY          ]   }  
  • 7. OFFSET and FETCH SELECT  ProductID,  Name     FROM  Production.Product   ORDER  BY  NAME     OFFSET  10  ROWS   FETCH  NEXT  5  ROWS  ONLY  
  • 8. THROW n  Bisher signalisierte man einen Fehler mit RAISERROR  (nnnnn,  16,   1)   n  Fehlermeldung musste in sys.messages existieren n  Fehler konnte nicht im CATCH-Block wiederholt werden n  Mit Throw kann eine beliebige Fehlernummer verwendet werden n  Ausführung von Throw ohne Parameter im CATCH Block wiederholt die auslösende Fehlermeldung
  • 9. THROW THROW [ { error_number | @local_variable }, { message | @local_variable }, { state | @local_variable } ][;]
  • 10. THROW BEGIN  TRY    BEGIN  TRANSACTION  -­‐-­‐  Start  the  transaction    -­‐-­‐  Delete  the  Customer    DELETE  FROM  Customers    WHERE  EmployeeID  =  ‘CACTU’      -­‐-­‐  Commit  the  change    COMMIT  TRANSACTION   END  TRY   BEGIN  CATCH    -­‐-­‐  There  is  an  error    ROLLBACK  TRANSACTION    -­‐-­‐  Re  throw  the  exception    THROW   END  CATCH  
  • 11. SEQUENCE n  Globale IDENTITY n  Steht nicht unter Transaktionskontrolle   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  }  ]          [  ;  ]  
  • 12. SEQUENCE CREATE  SEQUENCE  dbo.Seq  AS  INT   START  WITH  1   INCREMENT  BY  1;     CREATE  TABLE  dbo.Examp1   (      Seq  INT  NOT  NULL,      Name  VARCHAR(50)  NOT  NULL   );   INSERT  INTO  dbo.Examp1(Seq,  Name)  VALUES(NEXT  VALUE  FOR   dbo.Seq,  ‘Tom’);      
  • 13. Get Metadata of ResultSets n  Erzeugt detaillierte Beschreibung des Result Sets sp_describe_first_result_set     @tsql  =  N’SELECT  *  FROM  customers’    
  • 14. Andere Erweiterungen n  Weiter auf MSDN n  http://msdn.microsoft.com/en-us/library/cc645577.aspx
  • 15. Kurse Digicomp MOC  10774:  Wri-ng  Queries  with  Microso9  SQL  Server   2012  Transact-­‐SQL  (5  Tage)