The Real MTCS SQL Server 2008 Exam 70/432 Prep Kit- P101 ppt

5 94 0
The Real MTCS SQL Server 2008 Exam 70/432 Prep Kit- P101 ppt

Đang tải... (xem toàn văn)

Thông tin tài liệu

482 Chapter11•SQLServerXMLSupport  /*customerPhone–VARCHAR(255)*/'555-8746',  '<customer><address1>123MainStreet</address1><city>Newark  </city><state>DE</state><zip>14785</zip> </customer>') INSERTINTOXML_Table(  [customerName],  [customerPhone],  [customerAddress] )VALUES(  /*customerName-VARCHAR(255)*/'JenniferLiddle',  /*customerPhone–VARCHAR(255)*/'555-2497',  '<customer><address1>45AndrewStreet</address1><city>Clifton  </city><state>AH</state><zip>18783</zip> </customer>') To create the primary key for this table, you will use the code shown in Figure 11.3. Figure 11.3 Create Primary XML Index CREATEPRIMARYXMLINDEX[PK_XML_Data_customerAddress]  ONXML_Table(customerAddress) Secondary XML indexes are also created on a XML data type column. There are three types of secondary XML indexes (see Table 11.1). Secondary Index Description PATH XML index helps with queries that use XML path expressions. VALUE XML index helps with queries that search for values anywhere in the XML document. PROPERY XML index helps with queries that retrieve particular object properties from within an XML document. Table 11.1 Secondary XML Index Types SQLServerXMLSupport•Chapter11 483 To create a secondary XML index, you must use the CREATE XML INDEX statement. Figure 11.4 shows the syntax for the CREATE XML INDEX. Using the table you created in Figure 11.5, XML_Table, you will create a secondary XML index on the customerAddress column. CREATEXMLINDEXindex_name  ONtable_name(xml_column_name)  [USINGXMLINDEXxml_index_name   [FOR{VALUE|PATH|PROPERTY}] Figure 11.4 CREATE XML INDEX Syntax CREATEXMLINDEX[SD_XML_Data_customerAddress]  ONXML_Table(customerAddress) USINGXMLINDEX[PK_XML_Data_customerAddress] FORVALUE Figure 11.5 CREATE XML INDEX Usage Along with creating primary and secondary indexes on XML data type columns, you can also modify these indexes. The ALTER INDEX Transact-SQL DDL statement can be used to modify existing XML indexes. In Figure 11.6, you will modify your secondary index, DB_XML_Data_customerAddress, to turn ALLOW_ ROW_LOCKS OFF. XML indexes are ENABLED by default, but you can DISABLE an XML index. To do so, you set the XML index to DISABLE. You will DISABLE the secondary instance that you created (see Figure 11.7). ALTERINDEX[SD_XML_Data_customerAddress]ONXML_Table  SET(ALLOW_ROW_LOCKS=OFF) Figure 11.6 ALTER INDEX Usage ALTERINDEX[SD_XML_Data_customerAddress]onXML_TableDISABLE Figure 11.7 Using ALTER INDEX to DISABLE an Index 484 Chapter11•SQLServerXMLSupport Of course you can drop XML indexes. You use the DROP INDEX Transact- SQL DDL statement. If you drop the primary XML index, any secondary indexes that are present are also dropped. In Figure 11.8, you will drop the secondary index. Ex a m Wa r n i n g SQL Server HTTP endpoints are not supported on SQL Server 2008 Express Edition. HTTP Endpoints In SQL Server 2008, HTTP endpoints provide SQL server developers with new capabilities for using Web Services within SQL Server. It is worth noting that Web Services are not new to SQL Server 2008. SQL Server 2005 introduced HTTP endpoints and allowed you to consume Web Services and map them to SQL Server objects. DROPINDEX[SD_XML_Data_customerAddress]ONXML_Table Figure 11.8 Using DROP INDEX to DROP an XML Index Ex a m Wa r n i n g Native XML Web Services (SOAP/HTTP endpoints) has been deprecated in SQL Server 2008 Http Endpoints Defined HTTP endpoint enables developers to expose stored procedures and functions within a database as methods that can be called from any application using SOAP. SQL Server listens for HTTP requests natively on the server and then processes them; this requires fewer outside components to administer and easy application development and deployment. HTTP endpoint supports protocols such as HTTP, TCP, and payloads such as SOAP, TSQL, SERVICE BROKER, and Database Mirroring. SQLServerXMLSupport•Chapter11 485 Endpoint Can Interface to a Stored Procedure SQL Server stored procedures can be exposed to the HTTP endpoint, making any database object that can be executed or accessed in a stored procedure available to the endpoint. You will see an example of this in the next section. As always, it is very important to consider database security when setting up database objects to be accessed through an endpoint. Be sure to verify that the data that is being made available is safe for exposure to a web service. Underlying stored procedure calls or tables may inadvertently provide more access than intended. Always make sure that you are familiar with the data and any restrictions before providing access. How to Create the Endpoint To create an HTTP endpoint, you first need to determine what object you want to expose from SQL Server. You can expose stored procedures or user-defined functions as the endpoints for the mapping. In this example, you will create a stored procedure that will select against the tblhost table and tbl_host_thresholds table to return the first computer name in the results (see Figure 11.9). Next, you will create the endpoint for this procedure so that it can be used by an application. You can use the Create a 10-point command, as shown in Figure 11.10. CREATEPROCEDURE[dbo].[spGetThresholds] AS selectTop1b.csnamefromtblhost_thresholdsa innerjointblhostbona.hostid=b.id Figure 11.9 CREATE PROCEDURE Code for spGetThresholds CREATEENDPOINT[GetThresholds]  STATE=STARTED ASHTTP (  PATH=N'/Thresholds',  PORTS=(CLEAR),  AUTHENTICATION=(NTLM,KERBEROS,INTEGRATED),  SITE=N'W2K3SRVR', Figure 11.10 CREATE ENDPOINT Code for GetThresholds 486 Chapter11•SQLServerXMLSupport  CLEAR_PORT=80,  COMPRESSION=DISABLED) FORSOAP (  WEBMETHOD'Thresholds'(   NAME=N'[MS70432].[dbo].[spGetThresholds]',   SCHEMA=DEFAULT,   FORMAT=ALL_RESULTS),  BATCHES=DISABLED,  WSDL=DEFAULT,  SESSIONS=DISABLED,  SESSION_TIMEOUT=60,  DATABASE=N'MS70432',  NAMESPACE=N'http://MS70432/Thresholds',  SCHEMA=STANDARD,  CHARACTER_SET=XML ) The CREATE ENDPOINT has a number of key elements. You will see in your code that the STATE argument is set to STARTED, indicating that the HTTP endpoint listener is running. Review Table 11.2 for the options available for this argument. STATE Argument Description STARTED Endpoint is started and is actively listening for connections. STOPPED Endpoint is stopped. In this state, the server listens to port requests but returns errors to clients. DISABLED Endpoint is disabled. In this state, the server does not listen to the endpoint port or respond to any attempted requests to use the endpoint. Table 11.2 Settings Available for the STATE Argument . drop the secondary index. Ex a m Wa r n i n g SQL Server HTTP endpoints are not supported on SQL Server 2008 Express Edition. HTTP Endpoints In SQL Server 2008, HTTP endpoints provide SQL server. within SQL Server. It is worth noting that Web Services are not new to SQL Server 2008. SQL Server 2005 introduced HTTP endpoints and allowed you to consume Web Services and map them to SQL Server. methods that can be called from any application using SOAP. SQL Server listens for HTTP requests natively on the server and then processes them; this requires fewer outside components to administer

Ngày đăng: 07/07/2014, 00:20

Mục lục

    The Real MCTS SQL Server 2008 Exam 70-432 Prep Kit: Database Implementation and Maintenance

    Chapter 1: MCTS SQL Server 2008 Exam 432 New Features in SQL Server 2008

    A Word About the Test

    Enhanced Configuration and Management of Audits

    New Table Value Parameter

    Key Management and Encryption

    Resource Governor (similar to Query Governor)

    SQL Server 2008 Declarative Management Framework

    No Longer Requires IIS

    Export to Word Support

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan