USING XML DATA VARIABLES AND PARAMETERS lexical fidelity. Listing 8-4 illustrates what you can and cannot do with the XMLdata type in SQL statements. Listing 8-4: Using the XML Data Type in SQL Statements assume the same xml_tab as in previous examples comparison to NULL works SELECT the_id FROM xml_tab WHERE xml_col IS NULL illegal SELECT xml_col FROM xml_tab GROUP BY xml_col SELECT xml_col FROM xml_tab ORDER BY xml_col SELECT xml_col FROM xml_tab WHERE xml_col = SELECT SUBSTRING(xml_col,1,2) FROM xml_tab casting to string allows this to work SELECT xml_col from xml_tab WHERE CAST(xml_col AS VARCHAR) = Using XML Data Variables and Parameters SQL Server 2005 allows you to use the XML data type as a normal scalar variable in Transact-SQL. You can assign XML documents or fragments to the variable as you would any other variable. Usually, you will do this by casting or converting a character-based variable, as shown in this example. declare a variable of XML data type DECLARE @x XML cast a string to it (must be a valid XML document or fragment) SET @x = CAST( Bob AS XML) use it INSERT xml_tab VALUES(@x) Just as with an XML column, variables of the XML data type can be used as input to an assignment statement. Variables of the XML data type have the same processing limits as columns of the XML data type; they may not be used in place of a string in scalar functions such as SUBSTRING, in comparisons, or in ORDERBYor GROUPBYclauses in dynamic SQL, or as parameters, without first being cast or converted to a character data type. Stored

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

Bookmark the permalink.

Comments are closed.