Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 1 of 31 Objectives In this lesson, you will learn to: * Generate.

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

Microsoft Excel 2003 Illustrated Complete Excel Files and Incorporating Web Information Sharing.
Inside Data Access with SQLXML: Architecture Guide Rolandas Gricius MCT, MCSE, MCSD Adapted From.
ASP Tutorial. What is ASP? ASP (Active Server Pages) is a Microsoft technology that enables you to make dynamic and interactive web pages. –ASP usually.
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
1 COS 425: Database and Information Management Systems XML and information exchange.
Tutorial 11: Connecting to External Data
Module 9 Designing an XML Strategy. Module 9: Designing an XML Strategy Designing XML Storage Designing a Data Conversion Strategy Designing an XML Query.
SQL Server 2000 and XML Erik Veerman Consultant Intellinet Business Intelligence.
XP New Perspectives on Microsoft Access 2002 Tutorial 71 Microsoft Access 2002 Tutorial 7 – Integrating Access With the Web and With Other Programs.
DAT304 Leveraging XML and HTTP with Sql Server Irwin Dolobowsky Program Manager Webdata Group.
2.2 SQL Server 2005 的 XML 支援功能. Overview XML Enhancements in SQL Server 2005 The xml Data Type Using XQuery.
Rationale Aspiring Database Developers should be able to efficiently query and maintain databases. This module will help students learn the Structured.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Bookstore Web Application Introducing Visual Web Developer 2008 Express and the.
XML, CFMX CFML & SQL XML Kevin Penny, MMCP
9 Chapter Nine Extracting and Transforming Data with SQL Server 2000.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
XML in SQL Server Overview XML is a key part of any modern data environment It can be used to transmit data in a platform, application neutral form.
ACOT Intro/Copyright Succeeding in Business with Microsoft Excel
DATABASE and XML Moussa Mané. Learning Objectives ● Learn about Native XML Databases ● Learn about the conversion technology available ● Understand New.
Database Solutions for Storing and Retrieving XML Documents.
XML Overview. Chapter 8 © 2011 Pearson Education 2 Extensible Markup Language (XML) A text-based markup language (like HTML) A text-based markup language.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
SQL/lesson 2/Slide 1 of 45 Retrieving Result Sets Objectives In this lesson, you will learn to: * Use wildcards * Use the IS NULL and IS NOT NULL keywords.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 1 Quick Tutorial – Part 2 Open Data Web Services for Oracle BPM August, 2013 Forms.
Working with the XML Document Object Model ©NIITeXtensible Markup Language/Lesson 7/Slide 1 of 44 Objectives In this lesson, you will learn to: *Identify.
INSERT BOOK COVER 1Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Office Excel 2010 by Robert Grauer, Keith.
SQL/Lesson 4/Slide 1 of 45 Using Subqueries and Managing Databases Objectives In this lesson, you will learn to: *Use subqueries * Use subqueries with.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 6 Web Server & database.
DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.
5/24/01 Leveraging SQL Server 2000 in ColdFusion Applications December 9, 2003 Chris Lomvardias SRA International
Database control Introduction. The Database control is a tool that used by the database administrator to control the database. To enter to Database control.
Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET.
Microsoft SQL Server 2000 Cheng Ji November 3, 2003.
Module 18 Querying XML Data in SQL Server® 2008 R2.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Retrieving XML Data from SQL server.  Using the FOR XML Clause to Retrieve Data Retrieving Data in XML Format How SQL Server Generates XML Using the.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
Unit 10 Schema Data Processing. Key Concepts XML fundamentals XML document format Document declaration XML elements and attributes Parsing Reserved characters.
Working with XML Schemas ©NIITeXtensible Markup Language/Lesson 3/Slide 1 of 36 Objectives In this lesson, you will learn to: * Declare attributes in an.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Chapter 14 1 Chapter 14 Storing and Retrieving XML in SQL Server 2000 November 6, 2001 Sook-Kyo Kwon.
Session 1 Module 1: Introduction to Data Integrity
Accessing XML Documents Using DOM ©NIITeXtensible Markup Language/Lesson 8/Slide 1 of 23 Objectives In this lesson, you will learn to: * Use XML DOM objects.
ASP. ASP is a powerful tool for making dynamic and interactive Web pages An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are.
SQLXML XML Technology For SQL Server Brian Moore Developer and Platform Strategy Group Microsoft Corporation.
Module 3: Using XML. Overview Retrieving XML by Using FOR XML Shredding XML by Using OPENXML Introducing XQuery Using the xml Data Type.
DAT 405 Extreme SqlXml Irwin Dolobowsky Program Manager – SqlXml Microsoft Corporation.
Chapter 29. Copyright 2003, Paradigm Publishing Inc. CHAPTER 29 BACKNEXTEND 29-2 LINKS TO OBJECTIVES Attach an XML Schema Attach an XML Schema Load XML.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
XML Extensible Markup Language
Displaying Data with XSLT ©NIITeXtensible Markup Language/Lesson 6/Slide 1 of 45 Objectives In this lesson, you will learn to: * Perform conditional formatting.
In this session, you will learn to: Understand managed code Create managed database objects Define the Hypertext Transfer Protocol endpoints Implement.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
XML 1. Chapter 8 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SAMPLE XML SCHEMA (XSD) 2 Schema is a record definition, analogous to the.
Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 1 of 28 Objectives In this lesson, you will.
XML: Extensible Markup Language
Document Type Definition
Data Virtualization Tutorial: JSON_TABLE Queries
In this session, you will learn to:
Tutorial 7 – Integrating Access With the Web and With Other Programs
Objectives In this lesson, you will learn to:
Database SQL.
Presentation transcript:

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 1 of 31 Objectives In this lesson, you will learn to: * Generate an XML document by using data stored in SQL Server * Execute XPath queries against data stored in a SQL Server database * Insert XML data in a SQL Server database table

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 2 of 31 Getting Started * SQL Server 2000 has introduced features for integrating XML with SQL Server. * Some of these features are: 3 XPath queries 3 Direct URL queries 3 The OpenXML function 3 The FOR XML clause

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 3 of 31 Problem Statement 9.D.1 The details about the products sold at CyberShoppe are stored in a SQL Server 2000 database. This data needs to be displayed in a Web browser.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 4 of 31 Task List *Identify the mechanism for generating an XML document. *Build the query for generating the XML document. *Execute the query.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 5 of 31 Task 1: Identify the mechanism for generating an XML document. * SQL Server provides the SQL-XML mapping rules for extracting XML data from a database and storing XML data in the database. * The FOR XML clause of the SELECT statement is used to extract data from a database and display it as an XML document. * You can retrieve data in three different modes by using the FOR XML clause. 3 AUTO 3 RAW 3 EXPLICIT

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 6 of 31 Task 1: Identify the… XML document. (Contd.) * The syntax for using the FOR XML clause in the SELECT statement is as follows: SELECT table1.column_name1, table2.column_name2 FROM table1, table2 FOR XML mode Result * You can use the FOR XML clause of the SELECT statement to generate an XML document and display it in a browser.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 7 of 31 Task 2: Build the query for generating the XML document. * You need to create a URL query to display the XML document in a browser. * A URL query allows you to embed a SELECT statement along with the URL of a Web server to generate an XML document with the required data. * The syntax of a URL query is as follows: / ?sql= &root=rootelementname

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 8 of 31 Task 2: Build the … XML document. (Contd.) Result To display the data stored in a SQL Server 2000 database, you need to create a URL query. To be able to execute the URL query, you need to create a Web site and map the virtual directory of the Web site to the SQL Server database.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 9 of 31 Task 3: Execute the query.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 10 of 31 Just a Minute… What are the three modes that can be used with the FOR XML clause?

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 11 of 31 Just a Minute… The books table contains the details about the books sold at CyberShoppe. Write a query to generate an XML document based on the data stored in the books table. Also ensure that all columns from the table are displayed as elements and not attributes.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 12 of 31 Just a Minute… Identify the error in the following URL query. +EMPLOYEES FOR XML AUTO&root=root

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 13 of 31 Problem Statement 9.D.2 The details about the toys sold at CyberShoppe need to be displayed in a Web browser. The details are stored in the products table of the CyberShoppe database on SQL Server The CATEGORY column of the products table indicates the category of a product.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 14 of 31 Task List *Identify the method for converting only selective data. *Create an XML schema. *Build a query. *Execute the query.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 15 of 31 Task 1: Identify the method for converting only selective data. * SQL Server 2000 allows you to generate an XML document based on the data stored in a database. * You can use the FOR XML clause of the SELECT statement to generate an XML document and display it in a browser. * You can use XPath query to restrict the results returned in an XML document. * XPath query is an XML-based query language that can be used to process the data in an XML document. * To be able to use XPath queries, you need to create an XML schema. *XML Data Reduced language (XDR) is used to describe the content of an XML document.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 16 of 31 Task 1: Identify the method …data. (Contd.) Result To display only selective nodes from the resulting XML document, you can use XPath query. XPath queries use XML schemas for determining the structure of the XML document and traversing through various nodes. Therefore, you need to create an XML schema. Since SQL Server 2000 supports XDR schema language, you need to create a schema by using XDR.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 17 of 31 Task 2: Create an XML schema. The schema Element * Is the root element used in a file containing the schema for XML documents. * Marks the beginning of a schema definition. * The syntax for this element is as follows:

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 18 of 31 Task 2: Create an XML schema. (Contd.) The ElementType Element * Allows you to create an element type that can be used in a schema. * The syntax for the ElementType element of XDR is as follows: Content Model Declaration

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 19 of 31 Task 2: Create an XML schema. (Contd.) The AttributeType Element * Allows you to declare an attribute type, which can be used later in the schema.  The syntax for the AttributeType element of XDR is as follows:

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 20 of 31 Task 2: Create an XML schema. (Contd.) The element Element  Refers to an element type declared earlier in the schema by using the ElementType element. * Is used to declare the content model for another element type. * The syntax for this element is as follows:

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 21 of 31 Task 2: Create an XML schema. (Contd.) The attribute Element * Refers to an attribute type declared earlier in the schema by using the AttributeType element. * Is used to declare the content model for another element type. * The syntax for this element is as follows:

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 22 of 31 Task 3: Build a query. Task 4: Execute the query.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 23 of 31 Just a Minute… * The books sold at CyberShoppe are divided in to various categories, such as Science, Fiction, and Biography. The details about these books are stored in a SQL Server 2000 database. Create an XPath query for displaying the details about all fiction books. Also create a schema required for executing the query.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 24 of 31 Problem Statement 9.D.3 The branches of CyberShoppe send data about the sales made for various products in an XML document to the head office. On receiving this data, the head office needs to insert the details into a database table.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 25 of 31 Task List *Identify the data that needs to be inserted. *Identify the method for inserting XML data into a database. *Build a query. *Execute the query.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 26 of 31 Task 1: Identify the data that needs to be inserted. Result As per the scenario, the data that needs to be inserted into the SALES table is the sales details of the various products. The sales details includes the following: 3 ORDER 3 SHIP_ADD 3 PRICE_PER_QTY 3QUANTITY

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 27 of 31 Task 2: Identify the method for inserting XML data into a database. * The OPENXML function is used to retrieve the data from an XML document as a rowset. * SQL Server 2000 provides the following system stored procedures that can be used with the OPENXML function. 3sp_xml_preparedocument 3sp_xml_removedocument Result * You can use the OPENXML function with the sp_xml_preparedocument stored procedure to insert XML data into a database.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 28 of 31 Task 3: Build a query. Task 4: Execute the query.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 29 of 31 Just a Minute… * What are the system stored procedures that can be used with the OPENXML function?

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 30 of 31 Summary In this lesson, you learned that: *You can display data from a SQL Server 2000 database in a Web browser by using the SQL-XML integration feature. *To host a Web page, you need to install Internet Information Server (IIS) on a Windows 2000 or a Windows NT Server 4.0 system. If you have Windows NT Workstation 4.0 installed on a system, you can use Personal Web Server (PWS) instead of IIS. *The Virtual Directory Management option of SQL Server allows you to associate a SQL Server database with a virtual directory.

Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 31 of 31 Summary (Contd.) *The FOR XML clause forms a part of the T-SQL statement in a URL query. *In a URL query, / should precede the SQL statement. *The white spaces in the SELECT statement of URL Query must be substituted by the ‘+’ sign. *An XPath query is an XML-based query language that can be used to process the data in XML documents. *Data can be inserted in SQL Server 2000 tables using the sp_xml_preparedocument stored procedure and OpenXML function.