La Piattaforma Applicativa 3/29/2017 6:35 AM Sql Server 2005 Davide Mauri Factory Software davidem@factorysw.com La Piattaforma Applicativa © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Agenda T-SQL XML Ranking / Top n CTE Pivot / Unpivot Try … Catch 3/29/2017 6:35 AM Agenda T-SQL Ranking / Top n CTE Pivot / Unpivot Try … Catch Encryption XML Xml data type XQuery Full Text Search © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Agenda Integration Services Reporting Services Data e Control Flow 3/29/2017 6:35 AM Agenda Integration Services Data e Control Flow Connections Task Transformations Reporting Services Report Manager Sviluppo dei report con Visual Studio Report Builder © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM T-SQL © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
FUNZIONI di RANKING RANK DENSE_RANK NTILE ROW_NUMBER 3/29/2017 6:35 AM © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM RANK Ritona il “posizionamento” di ogni riga all’interno di una partizione PARTITION BY definisce il criterio di partizionamento ORDER BY stabilisce l’ordine in cui viene appicato il rank alle righe Sintassi: SELECT select_list, RANK() OVER (PARTITION BY col1 ORDER BY col2) as rank FROM Tabella1 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
RANK RANK = 1 + numero di rank che precedono la riga 3/29/2017 6:35 AM RANK RANK = 1 + numero di rank che precedono la riga Se due o più righe sono alla pari, ricevono lo stesso rank I rank potrebbero non essere numeri consecutivi © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
DENSE_RANK RANK = 1 + numero di DISTINCT rank che precedono la riga 3/29/2017 6:35 AM DENSE_RANK RANK = 1 + numero di DISTINCT rank che precedono la riga Se due o più righe sono alla pari, ricevono lo stesso rank Non vi sono “gap” nei rank SELECT select_list, DENSE_RANK() OVER (PARTITION BY col1 ORDER BY col2) as rank FROM Tabella1 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM NTILE Distribuisce le righe di una partizione ordinata in uno specificato numero di gruppi Se il numero di righe non è divisibile per il numero di gruppi I gruppi avranno ampiezza differente Prima compariranno i gruppi con più elementi SELECT select_list, NTILE(nr_gruppi) OVER (PARTITION BY col1 ORDER BY col2) as rank FROM Tabella1 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM ROW_NUMBER Ritorna il numero sequenziale di una riga all’interno di una partizione ordinata SELECT select_list, ROW_NUMBER() OVER (PARTITION BY col1 ORDER BY col2) as rank FROM Tabella1 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
TOP Specifica che solo la prima parte di un result set verrà ritornata 3/29/2017 6:35 AM TOP Specifica che solo la prima parte di un result set verrà ritornata PERCENT WITH TIES (+ order by) TOP @variabile © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
COMMON TABLE EXPRESSION (CTE) 3/29/2017 6:35 AM COMMON TABLE EXPRESSION (CTE) Result set temporaneo Non è salvato come oggetto Rimane in vita solo per la durata della query che lo ospita Migliora la leggibilità e la manutenibilità delle query © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
CTE: Utilizzo Query ricorsive 3/29/2017 6:35 AM CTE: Utilizzo Query ricorsive Anchor Member e Recursive Member Quert hint: option (maxrecursion n) Sostituto delle view (quando non serve salvare i metadati) Referenziare lo stesso result set più volte nella query © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
CTE: Sintassi Struttura della CTE: Utilizzo: 3/29/2017 6:35 AM CTE: Sintassi Struttura della CTE: WITH nome_cte [(nome colonna,…)] AS (query che definisce la CTE) Utilizzo: SELECT * FROM nome_cte © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM PIVOT Ruota un’espressione tabellare trasformando i valori univoci di una colonna nelle colonne dell’espressione di output Effettua le aggregazioni che costituiscono l’output SELECT VendorID, [164] AS Emp1, [198] AS Emp2, [223] AS Emp3, [231] AS Emp4 FROM ( SELECT PurchaseOrderID, EmployeeID, VendorID FROM Purchasing.PurchaseOrderHeader ) p PIVOT( COUNT (PurchaseOrderID) FOR EmployeeID IN ( [164], [198], [223], [231] )) AS pvt © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
UNPIVOT Effettua l’operazione inversa rispetto a PIVOT 3/29/2017 6:35 AM UNPIVOT Effettua l’operazione inversa rispetto a PIVOT Ruota le colonne in righe I valori nulli non possono essere usati SELECT VendorID, Employee, Orders FROM (SELECT VendorID, Emp1, Emp2, Emp3, Emp4 FROM pvt) p UNPIVOT (Orders FOR Employee IN (Emp1, Emp2, Emp3, Emp4, Emp5) )AS unpvt GO © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Error handling Gestione simile al C# / VB.NET attraverso TRY e CATCH: 3/29/2017 6:35 AM Error handling Gestione simile al C# / VB.NET attraverso TRY e CATCH: Se si verifica un errore nel blocco TRY il controllo passa al blocco CATCH. Eseguito il blocco CATCH il controllo passa al codice che sta dopo END CATCH Blocco TRY Exception Blocco CATCH Codice Successivo a END CATCH Nessuna Exception © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Sintassi di TRY...CATCH Sintassi: BEGIN TRY ... END TRY BEGIN CATCH 3/29/2017 6:35 AM Sintassi di TRY...CATCH Sintassi: BEGIN TRY ... END TRY BEGIN CATCH .... Gestione dell’errore ..... END CATCH Il batch è unico!!!! © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM Try...catch TIPS Ogni TRY..CATCH deve essere contenuto in un unico BATCH, Stored Procedure, Trigger I blocchi TRY…CATCH possono essere nidificati Errori con severity <= 10 sono warning che non vengono intercettati dal blocco CATCH Errori con severity >= 20 che causano l’interruzione della connessione: Non sono gestiti da TRY…CATCH Tuttavia finchè la connessione non è interrotta il blocco CATCH funziona. © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM Try...catch e XACT_STATE Nel blocco catch è bene controllare lo stato della transazione attraverso XACT_STATE() 1: Transazione attiva, la sessione può compiere qualsiasi azione (COMMIT o ROLLBACK) 0: Nessuna transazione attiva -1: Esiste una transazione aperta, ma NON può essere eseguito il COMMIT. BEGIN CATCH IF (XACT_STATE()) = -1 ROLLBACK TRANSACTION; IF (XACT_STATE()) = 1 COMMIT TRANSACTION; END CATCH © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Informazioni sugli errori 3/29/2017 6:35 AM Informazioni sugli errori ERROR_MESSAGE() ERROR_NUMBER() ERROR_SEVERITY() ERROR_STATE() ERROR_PROCEDURE() ERROR_LINE() Ritornano informazioni solo all’interno di un blocco CATCH. Posso utilizzate una stored procedure per il logging © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
TRY...CATCH: tips Utilizzo di RAISERROR per il rethrow Intercetta: 3/29/2017 6:35 AM TRY...CATCH: tips Utilizzo di RAISERROR per il rethrow Intercetta: Deadlock errors Non intercetta: Errori di compilazione tipo syntax error Statement level recompilation errors (object name resolution errors) © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
ENCRYPTION Possibilità di criptare i valori tramite l’utilizzo di EncryptKey DecryptKey Utilizzabili negli statement DML Solo chi è in possesso della chiave giusta potrà vedere il valore Gli altri vedranno NULL © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM XML © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML in un Database Relazionale? 3/29/2017 6:35 AM XML in un Database Relazionale? E’ lo standard de facto Utilizzato come Lingua Franca Dati trasmessi e ricevuti come XML Sempre più utilizzato I database prima o poi devono cominciare a fare i conti con questa realtà Allora meglio farlo nel modo migliore © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML in un Database Relazionale? 3/29/2017 6:35 AM XML in un Database Relazionale? XML può vivere all’interno del db in 3 modi 1. TEXT Come accade con Sql Server 2000 Si perdono le funzionalità intrinsche di XML © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML in un Database Relazionale? 3/29/2017 6:35 AM XML in un Database Relazionale? 2. RELATIONAL FORMAT Se possibile un documento può essere scomposto in tabelle Si sfruttano le capacità del motore relazionale Si ottiene tramite OPENXML o XMLBULKLOAD (SqlXml) © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML in un Database Relazionale? 3/29/2017 6:35 AM XML in un Database Relazionale? 3. XML Data Type Utilizzo di tutte le funzionalità di xml Supporto ricerche full-text Supporto validazione Utilizzabile in ogni situazione Colonne, Parametri, Variabili, Return Value Attenzione non abusarne Violazione della forma normale © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML in un Database Relazionale? 3/29/2017 6:35 AM XML in un Database Relazionale? Perchè dovrei?!?! Memorizzazione di documenti XML Memorizzazione di dati destrutturati Sistemi Integrati B2B (Business To Business)/B2C (Business To Consumer) A2A (Application To Application) Messaging (SOAP) Occhio a non sentirsi “obbligati” Ogni tanto la si cerca di usare solo perchè è nuova o perchè non si conoscono alternative © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML in un Database Relazionale 3/29/2017 6:35 AM XML in un Database Relazionale Una colonna XML può memorizzare well-formed XML Fragments Documents © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML in un Database Relazionale 3/29/2017 6:35 AM XML in un Database Relazionale Pieno supporto e gestione dell’encoding -- This works correctly INSERT INTO xml_tab VALUES(4, '<?xml version="1.0" encoding="utf-8"?> <doc1> <row au_id="111-11-1111"/> </doc1>') -- This fails, encoding does not agree w/variable type INSERT INTO xml_tab VALUES(5, N'<?xml version="1.0" encoding="utf-8"?> <row au_id="111-11-1111"></row> © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM Typed & Untyped XML E’ possibile fare in modo che il tipo XML sia validato da un XML Schema Per validare i dati inseriti Per assicurarsi che tutte le entità abbiano la stessa struttura Definizione dei tipi di dati utilizzati © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Constrained XML E’ possibile anche utilizzare il vincolo CHECK 3/29/2017 6:35 AM Constrained XML E’ possibile anche utilizzare il vincolo CHECK Constrained XML CREATE TABLE docs ( pk INT PRIMARY KEY, xCol XML not null CONSTRAINT CK_name CHECK (xCol.exist('/book/author[first-name = last-name]') = 0) ) © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML Schema Collections 3/29/2017 6:35 AM XML Schema Collections Gli XML Schema utilizzati devono essere nel database CREATE XML SCHEMA COLLECTION Il nome verrà utilizzato nell’associazione con il tipo di dato Lo schema deve essere inserito come literal © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML Schema Collections 3/29/2017 6:35 AM XML Schema Collections CREATE XML SCHEMA COLLECTION geocoll literal schema '<xs:schema ... targetNamespace targetNamespace = urn:geo> ... </xs:schema>' CREATE TABLE Locations reference to ( schema collection location xml(geocoll) ... ) Memorizzazione nella tabelle di sistema sys.xml_schema_collections sys.xml_schema_namespaces © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML Schema Sample f or namespace urn:geo similar to sql type, <xs:schema xmlns:xs= "http://www.w3.org/2001/XMLSchema" targetNamespace="urn:geo" xmlns:tns="urn:geo"> <xs:simpleType name="dim"> <xs:restriction base="xs:int"/> </xs:simpleType> <xs:complexType name=" Point "> <xs:sequence> <xs:element name="X" type="tns:dim"/> <xs:element name="Y" </xs:sequence> </xs:complexType> <xs:element name="Point" type="tns: "/> </xs:schema> f or namespace urn:geo similar to sql type, structured type, i.e. a tree element that might appear in xml data © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Utilizzo di Typed XML CREATE TABLE point_tab( 3/29/2017 6:35 AM Utilizzo di Typed XML CREATE TABLE point_tab( id int IDENTITY primary key, -- geocoll include schema for 'urn:geo' namespace thepoint xml(CONTENT, geocoll) GO -- this works, schema-valid Point INSERT INTO point_tab VALUES( '<Point xmlns="urn:geo"><X>10</X><Y>20</Y></Point>') -- this insert fails, value foo is not a dim (integer) '<Point xmlns="urn:geo"><X>10</X><Y>foo</Y></Point>') © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML Schema Collections 3/29/2017 6:35 AM XML Schema Collections L’ XML schema non è realmente memorizzato nel database Il contenuto è scomposto e memorizzato in tabelle di sistema Solo le imformazioni fondamentali vengono memorizzate Informazioni non memorizzate Comments, Processing Instructions <xs:annotation> © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML Schema Collections 3/29/2017 6:35 AM XML Schema Collections Ottenere lo schema memorizzato sys_schema_namespace(…, …) Non è lo schema orginale Ma è Functionally Equivalent select xml_schema_namespace(N’dbo’, N’geocollection’) © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
FOR XML Risultato memorizzabile in una varibile 3/29/2017 6:35 AM FOR XML Risultato memorizzabile in una varibile Tramite la keywork TYPE Nuova keywork PATH per effettuare lo shaping dell’XML Più semplice da usare che EXPLICIT DECLARE @x xml SET @x = SELECT * FROM authors FOR XML AUTO, TYPE © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
FOR XML SELECT au_id as [@authorid], au_fname as [name/firstname], au_lname as [name/lastname] FROM authors FOR XML PATH <!– one row per selected row --> <row authorid="111-11-1111"> <name> <firstname>Bob</firstname> <lastname>Smith</lastname> </name> </row> ... © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML BULK LOAD I dati XML possono essere popolati tramite BULK LOAD © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XQuery XQuery è l’evoluzione di XPath Supporto di un subset di XQuery 3/29/2017 6:35 AM XQuery XQuery è l’evoluzione di XPath Più correttamente è un SuperSet Supporto di un subset di XQuery implementazione basata con il draft Novembre 2003 http://www.w3.org/TR/xquery Permette di poter fare query su dati semistrutturati e/o destrutturati XML © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XQuery XQuery fatta da “FLWOR” Expressions: 3/29/2017 6:35 AM XQuery XQuery fatta da “FLWOR” Expressions: FOR LET (not supported) WHERE ORDER BY RETURN Può lavorare direttamente sull’ XML Data Type sia come variabile sia come colonna © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XQuery Possibilità di utilizzare sia query XPath che FLWOR 3/29/2017 6:35 AM XQuery Possibilità di utilizzare sia query XPath che FLWOR (: this is a valid XQuery :) /people/person[age > 30] (: so is this FLWOR expression :) for $p in /people/person where $p/age > 30 order by $p/age[1] return $p/name © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XQuery -- returns <li>moe in record number x</li> 3/29/2017 6:35 AM XQuery -- returns <li>moe in record number x</li> -- where x is the ID column, or blank column SELECT xml_col.query(' for $b in //person where $b/@name=“davide" return <li>{ data($b/@name) } in record number {sql:column("xml_tab.id")}</li> ') FROM xml_tab -- returns <li>moe is a stooge</li> DECLARE @occupation VARCHAR(50) SET @occupation = ' is a singer' SELECT xml_col.query(' for $b in //person where $b/@name=“eric" return <li>{ data($b/@name) } {sql:variable("@occupation") }</li> ') FROM xml_tab © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XQuery & Xml Data Type Xml Data Type Functions exist() value() query() 3/29/2017 6:35 AM XQuery & Xml Data Type Xml Data Type Functions exist() value() query() nodes() modify() SELECT xmlCol.query(‘/Root/ProdDesc/*’) FROM myTable © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
xml.exist() xml.exist usa XML type and XQuery expression 3/29/2017 6:35 AM xml.exist() xml.exist usa XML type and XQuery expression false se la query restituisce NULL true negli altri casi Può essere utilizzato in constraint di tipo CHECK © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
xml.exist() Supporto per DEFAULT -- pdoc must have a person element 3/29/2017 6:35 AM xml.exist() -- pdoc must have a person element -- as a child of the people root CREATE TABLE xmltab( id INTEGER PRIMARY KEY, pdoc XML CHECK (pdoc.exist('/people/person')=1) ) -- ok insert xmltab values( 1, '<people><person name="bob"/></people>') -- fails, no persons insert xmlpeople values( 2, '<people><emp name="fred"/></people>') Supporto per DEFAULT © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM xml.value() xml.value restituisce un tipo di dato nativo SQL Server e scalar input: XQuery, SQL Type restituisce un tipo scalare o NULL non può restituire un tipo XML Utilizzo predicati (es. WHERE Clause) result values views © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
xml.value() -- insert some rows INSERT xml_tab 3/29/2017 6:35 AM xml.value() -- insert some rows INSERT xml_tab VALUES('<people><person name=“alessandro"/></people>') VALUES('<people><person name=“davide"/></people>') VALUES('<people><person name=“franco"/></people>') -- this query SELECT id, xml_col.value('/people/person/@name','varchar(50)') AS name FROM xml_tab -- yields this resultset id name -------------------------- 1 alessandro 2 davide 3 franco © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
xml.query() xml.query resituisce un XML data type input: XQuery 3/29/2017 6:35 AM xml.query() xml.query resituisce un XML data type input: XQuery l’xml risultante può essere un XML Fragment può costruire nuovi elementi <Invoice> <LineItem>Soda</LineItem> Colonna Invoice, Tabella Invoices <LineItem>Ice</LineItem> </Invoice> SELECT invoice.query('Invoice/LineItem') FROM Invoices <LineItem>Soda</LineItem><LineItem>Ice</LineItem> © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
xml.nodes() scompone il contenuto di un XML data type 3/29/2017 6:35 AM xml.nodes() scompone il contenuto di un XML data type simile (concettualmente) a value(), ma produce dei nodi, non un valore scalare il risultato è un rowset il risultato può essere application al comando T-SQL CROSS APPLY si ottengono funzionalità simili ad OPENXML performance migliori © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM xml.nodes() --input xml in variable @x <row id=“1”><name>alessandro</name><name>davide</name></row> <row id=“2”><name>franco</name></row> <row id=“3/> -- this query SELECT ... FROM @x.nodes(‘//row’) T(rows) -- yields this resultset id name -------------------------- 1 alessandro 1 davide 2 franco © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Using Relational Data in XQuery 3/29/2017 6:35 AM Using Relational Data in XQuery SQL Server XQuery può utilizzare sia dati XML che dati relazionali sql:variable: accesso a variabili T-SQL sql:column: accesso a columns value limitatamente alla riga in uso © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Using Relational Data With XML 3/29/2017 6:35 AM Using Relational Data With XML -- returns <li>moe in record number x</li> -- where x is the ID column, or blank column SELECT xml_col.query(' for $b in //person where $b/@name=“Eric" return <li>{ data($b/@name) } in record number {sql:column("xml_tab.id")}</li> ') FROM xml_tab -- returns <li>moe is a stooge</li> DECLARE @occupation VARCHAR(50) SET @occupation = ' is a stooge' SELECT xml_col.query(' for $b in //person where $b/@name=“Bruce" return <li>{ data($b/@name) } {sql:variable("@occupation") }</li> ') FROM xml_tab © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM XQuery DML © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XQuery DML xml.modify permette la modifica di XML XQuery non ha standard DML vengono utilizzati gli standard proposti insert, delete, replace operators all’interno di espressioni XQuery insert before or after element first or last sibling subelements and attributes must be a single node replace elements or attributes solo simple types “value-of" clause per aggiornare i valori © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XQuery DML - Original Document 3/29/2017 6:35 AM XQuery DML - Original Document declare @x xml set @x = '<Invoice> <InvoiceID>1000</InvoiceID> <CustomerName>Jane Smith</CustomerName> <LineItems> <LineItem> <Sku>134</Sku> <Quantity>10</Quantity> <Description>Chicken Patties</Description> <UnitPrice>9.95</UnitPrice> </LineItem> <Sku>153</Sku> <Quantity>5</Quantity> <Description>Vanilla Ice Cream</Description> <UnitPrice>1.50</UnitPrice> </LineItems> </Invoice>' © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XQuery DML - Using xml.modify 3/29/2017 6:35 AM XQuery DML - Using xml.modify -- use modify to insert a subelement SET @x.modify( 'insert <InvoiceDate>2002-06-15</InvoiceDate> into /Invoice[1] ') -- or insert an attribute SET @x.modify('insert attribute status{"backorder"} -- this deletes all LineItem elements SET @x.modify('delete /Invoice/LineItems/LineItem') -- change the value of the CustomerName element SET @x.modify('replace value of /Invoice[1]/CustomerName[1]/text()[1] with "John Smith" ') © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML Full Text Search XML filter Index e query su istanze XML 3/29/2017 6:35 AM XML Full Text Search XML filter Index e query su istanze XML Analisi sul contenuto di un token I tag (attributi inclusi) sono rimossi Sintassi — come per le altre colonne CREATE FULLTEXT INDEX ON docs (xDoc) © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
XML Full Text Search Può essere combinata con XQuery 3/29/2017 6:35 AM XML Full Text Search Può essere combinata con XQuery Full-text search come filtro, poi XQuery search SELECT R.X.query ('//sec[@num=12]') FROM (SELECT * FROM docs WHERE contains (xDoc, 'Wrd1 Wrd2')) R(X) Supporta l’attributo xml:lang Utilizza correttamente il linguaggio SELECT * FROM docs WHERE contains (xDoc, 'Visionen', LANGUAGE 'German') © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Integration Services 3/29/2017 6:35 AM © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Architettura ed Object Model 3/29/2017 6:35 AM Architettura ed Object Model Separazione dei package in due aree Control Flow Data Flow Modello ad oggetti facilmente estendibile basato sul .NET Framework Non limitato ai soli Custom Task © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Architettura ed Object Model 3/29/2017 6:35 AM Architettura ed Object Model Supporto per sorgenti e destinazioni multiple Supporto nativo XML, SQL CE 2005, AS 2005 come sorgenti/destinazione dati Introduzione delle DTS Expression Una sorta di linguaggio interno Vagamente simile a C# © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Ambiente di sviluppo BI Development Studio Praticamente è Visual Studio Designer molto più ordinato tramite l’utilizzo di aree “tematiche” Supporto per sistemi di gestione del codice Visual SourceSafe Migliorate le capacità di debugging © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Package Elements Numerosi nuovi task 3/29/2017 6:35 AM Package Elements Numerosi nuovi task Data Flow Data Preparation Workflow Sql Server Scripting Analisys Server Maintenance Aggiunto il supporto per i Containers Loop, For Each, Sequence, ecc… © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Tools Wizard per: DTExecUI e DTExec DTUtil Configurazione dei Package 3/29/2017 6:35 AM Tools Wizard per: Configurazione dei Package Deployment e Update Migrazione dai DTS di SQL Server 2000 DTExecUI e DTExec Esecuzione dal prompt DTUtil Gestione dal prompt (copy, crypt, sign…) © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Package Management E’ possibile utilizzare dei Folder per fare ordine 3/29/2017 6:35 AM Package Management E’ possibile utilizzare dei Folder per fare ordine Logging non limitato alle trasformazioni Supporto nativo per la configurazione del package senza necessità di utilizzo dell’ambiente di editing Package Checkpointing © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM Sviluppo Molti elementi permettono l’utilizzo di un “Linguaggio” interno: DTS Expressions Possibilità di creare workflow molto complessi Possibilità di gestire gli eventi (es. OnError) Programmabili ed estendibili con .NET © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM Packages © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Package Content Un Package può contenere: Control Flow Data Flow 3/29/2017 6:35 AM Package Content Un Package può contenere: Control Flow Task Container Data Flow Trasformations Connections Configurations Variables © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Operational Surfaces Control Flow Data Flow Event Handlers 3/29/2017 6:35 AM Operational Surfaces Control Flow Data Flow Event Handlers Package Explorer Execution Results Connection Managers Properties © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Control Flow Descrive l’intero processo definito dal Package 3/29/2017 6:35 AM Control Flow Descrive l’intero processo definito dal Package Organizza i task e specifica percorsi e/o precedenze Il workflow è basato sul risultato di un’espressione DTS Praticamente nessun limite alla fantasia! © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Data Flow Descrive il flusso dei dati (Pipeline) 3/29/2017 6:35 AM Data Flow Source Transform Destination Descrive il flusso dei dati (Pipeline) Specifica dettagliatamente tutto ciò che riguarda la manipolazione dei dati E’ un task del Control Flow © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Connection Managers Le connessioni visualizzate in uno spazio dedicato 3/29/2017 6:35 AM Connection Managers Le connessioni visualizzate in uno spazio dedicato Non solamente dedicate ai database Es. SMTP Connection Manager, FTP Connection Manager Condivise sia dagli elementi del Control Flow che del Data Flow © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Control Flow Elements Tre diversi tipi di Container: 3/29/2017 6:35 AM Control Flow Elements Tre diversi tipi di Container: Possibilità di effettuare dei loop: For Loop ForEach Loop Raggruppamento di task Sequence © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM Control Flow Elements Numerosi nuovi task che evitano la scrittura di codice Data Flow Task Per la definizione dettagliata dei processi di ETL File System Task Per la gestione dei file e delle directory (Create, Copy, Move, Delete, Rename, Set Attributes) © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Control Flow Elements Script Task Send Mail Task FTP Task 3/29/2017 6:35 AM Control Flow Elements Script Task Esecuzione di script scritti in VB.NET Editor *finalmente* evoluto Send Mail Task Supporto SMTP (Era Ora! ) FTP Task Supporto per tutte le operazione non solo il GET © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Control Flow Elements WMI Data Reader Task WMI Event Watcher Task 3/29/2017 6:35 AM Control Flow Elements WMI Data Reader Task Per ottenere informazioni da WMI WMI Event Watcher Task Per monitorare i dati di WMI e rispondere ai cambiamenti XML Task Per operare su documenti XML (XSLT, Merge, Patch, Diff, Validate, XPath) © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Data Flow Elements Conditional Split Transform Multicast Transform 3/29/2017 6:35 AM Data Flow Elements Conditional Split Transform Per processare una riga secondo diversi criteri Multicast Transform Permette di processare una riga più volte e con diversi meccanismi Union All Transform Prende più input e di generare un solo output © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Data Flow Elements Sort Transformation Count Rows Transformation 3/29/2017 6:35 AM Data Flow Elements Sort Transformation Per ordinare le righe Count Rows Transformation Per contare le righe Derived Column Per modificare o creare colonne © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Data Flow Elements Fuzzy Grouping Fuzzy Lookup Percentage Sampling Pulisce e standardizza i dati (Es. Rimuove i duplicati) Fuzzy Lookup Pulisce ulteriormente i dati (Es. Standardizzazione, Correzione ed inserimento valori mancanti) Percentage Sampling Crea dati di prova © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Data Viewers Attivi durante il debug 3/29/2017 6:35 AM Data Viewers Attivi durante il debug Permettono di interrompere l’esecuzione di un Data Flow visualizzare i dati E’ possibile vedere anche la distribuzione dei dati con l’ausilio di grafici © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Reporting Services 3/29/2017 6:35 AM © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Reporting Services Editor Report: BI Dev. Studio 3/29/2017 6:35 AM Reporting Services Editor Report: BI Dev. Studio Non è obbligatorio in quanto il report è un file xml Però è praticamente indispensabile Creare un progetto di tipo “Report Project” Aggiungere: Data Sources Parametri Reports © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM Reporting Services Ogni proprietà visibile (e non) può essere modificata tramite l’uso di expressions Il linguaggio è VB.NET In più ci sono funzioni aggiunte dall’infrastruttura di SSRS Previous RowNumber CountRows © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Sviluppo E’ possibile aggiungere funzioni tramite Codice Embedded (VB.NET) External Assembly (Qualsiasi linguaggio .NET) Per personalizzare il report è possibile utilizzare immagini Memorizzate nel report (embedded) Esterne (link) Memorizzata in un db © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM Reporting Services Il Report Manager è “solamente” l’applicazione di default fornita da Microsoft Utilizza il web service per visualizzare i metadati e gestire i report I report vengono visualizzati in un IFRAME E sono chiamati tramite URL © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM Reporting Services E’ possibile integrare SSRS in qualsiasi applicazione tramite Chiamate SOAP (Web Services) Chiamate via URL E’ possibile integrare il tutto con SharePoint Web part disponibile dalla SP2 dei “vecchi” RS © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Reporting Services Creazione di report ad-hoc 3/29/2017 6:35 AM Reporting Services Creazione di report ad-hoc Tramite il Report Builder Non c’è un liberta “totale” I report possono essere creati sulla base di un “Report Model” Il “Report Model” contiene i metadati disponibili Più che sufficiente nel 99% dei casi Il “Report Model” si crea da Visual Studio © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Reporting Services 3/29/2017 6:35 AM © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM Invocazione di Report E’ possibile accedere a Reporting Services in una soluzione custom in due modalita’: Url access richiesta via HTTP/GET Web Services Richiesta via SOAP © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Invocazione di Report 3/29/2017 6:35 AM © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Invocazione di Report Url Access Report Server URL Report Name Defaults to http://[servername]/ReportServer Report Name Nome del report Report Parameters I nomi devono mappare I parametri definiti nel report Es http://servername/ReportServer/ReportName? CategoryID=1&EmployeeID=1 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Invocazione di Report Web Services Esecuzione dei report 3/29/2017 6:35 AM Invocazione di Report Web Services Esecuzione dei report GetReportParameters() Render() Anche asincrona Gestione report CreateReport() GetReportDefinition() © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Distribuzione dei report 3/29/2017 6:35 AM Distribuzione dei report I report possono essere visualizzati Da web, tramite il Report Manager Da applicazioni ad hoc, o integrati in applicazioni esistenti …ma possono anche essere loro ad andare dall’interessato Via mail Via network share Questa funzionalità prendere il nome di Subscription © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Distribuzione dei report 3/29/2017 6:35 AM Distribuzione dei report Le subscription vengono eseguite in base ad una schedulazione Ad hoc Condivisa La schedulazione fa affidamento sul SQL Server Agent Quindi deve essere attivo! Vengono creati dei Job ad hoc © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Distribuzione dei report 3/29/2017 6:35 AM Distribuzione dei report Distribuzione tramite network share © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Distribuzione dei report 3/29/2017 6:35 AM Distribuzione dei report Distribuzione via email © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Distribuzione dei report 3/29/2017 6:35 AM Distribuzione dei report Le sottoscrizioni guidate (Data-Driven subscription) permettono di impostare a runtime Destinatari Parametri Formati I dati vengono prelevati tramite query ad hoc La sorgente dati, come al solito, può essere qualsiasi cosa (SQL Server, Oracle, OLEDB, ODBC) © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3/29/2017 6:35 AM Domande ? © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
© 2004 Microsoft Corporation. All rights reserved. 3/29/2017 6:35 AM © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.