Label:Use sp_xml_preparedocument to read XML text. Reads the XML text provided as input, then parses it using the MSXML parser (Msxmlsql.dll) and provides the parsed document for use. The parsed document is a tree representation of each node (element, attribute, text, comment, and so on) in the XML document. Prepare an internal representation for a properly forma
Tags: ide font arch ACE float table name Process class styleIn the development process often need to write the corresponding entity class according to the data table, the following is the use of SQL statements to quickly convert the data table to the corresponding entity class code, use only the first line of ' TableName ' quotation marks inside the letter to the specific table name on the line: Declare @Ta
In the design of the database, often do not take into account the problem of table partitioning, often in the burden of the data table load is getting heavier, will take into account the partitioning method, at this time, it is related to how to convert the ordinary table to the problem of the Component table.So, how do you convert a normal table into a partitioned table? In the final analysis, simply creat
SQL Server Date functionDefinition and usageThe CONVERT () function is a general function that converts a date to a new data type.The CONVERT () function can display date/time data in different formats.GrammarCONVERT (data_type (length),data_to_be_converted,style)data_type (length) Specifies the target data type (with an optional length). data_to_be_converted con
Tags: idt com Arch SQL img nbsp span format imaThe CONVERT function converts the time to a new type of common format , which makes it easy to query CONVERT (Type,expression,style) Type: For example: varchar (10) database string types, size can be self-determined Expression: A field representing time Style: Format, the
functionReturns an expression that is converted to the provided data type.GrammarCONVERT (data type, expression [, Format-style])Cases:CONVERT (varchar (8), GETDATE (), 112)parametersThe data type to which the type expression will be converted.Expression to convert.Format-style for converting a string to a date or time data type and to the reverse conversion process, Format-style is a style code that describes the date format string to use. The value
SQL CONVERT () string int-type Date character type
Convert to date notation
Convert (data_type (length), Data_to_be_converted,style)
Instance
Select CONVERT (varchar), GETDATE (), () now
capabilities for searching and integrating traditional SQL and XML data.
Sample Database
The query in this article accesses the sample database that was created in the "DB2 Viper QuickStart" (developerworks,2006 year April). Here we briefly review the definition of "items" and "clients" tables in the sample database:Listing 1. Definition of a table
CREATE TABLE items (
ID int PRIMARY key NOT NULL,
bra
XQuery. SQL embedded in XQuery allows you to run external functions on XML columns. However, if you want to perform data analysis queries with groups and aggregation, SQL/XML is a better choice.
No matter how you choose to combine SQL and XQuery in a statement, DB2 uses a
SQL query case: convert a column to a row using UNION ALL.
After the conversion of rows and columns, you may encounter the need to replace columns.
Create table TestColRow (Name VARCHAR (10 ),East INT,South INT,West INT,North INT);
Insert into TestColRowVALUES ('zhang san', 1, 2, 3, 4 );
Insert into TestColRowVALUES ('Lee 4', 5, 6, 7, 8 );
Processing with
There are two ways to export an XML file: A direct export to an XML file, no need to create a table to store XML text to the database, but if the value of the Chinese language can not open the XML file normally, to be studied, on the code: it is important to note that the query data when the table must be followed with
The operation code for XML columns in SQLServerTable. For more information, see.
The operation code of XML columns in SQL Server Table. For more information, see.
The Code is as follows:
-- Create a test table
DECLARE @ Users TABLE
(
Id int identity (1, 1 ),
UserInfo XML
)
--- Insert Test Data
DECLARE @
sure to save it; @ xmltext: the XML text you actually want to process; @ xml_namespaces: any namespace index (namespace references) required for normal operation of your XML data ). Note that any URL that appears here must be enclosed by Angle brackets (
OPENXML (idocint [in], rowpatternnvarchar [in], [flagsbyte [in])
[WITH (SchemaDeclaration | TableName)]
Note: there is not enough text in this article to
Reference:Http://www.cnblogs.com/repository/archive/2011/01/18/1938418.htmlSelect CONVERT (varchar), c.[startspecday],120, (SELECT [leavename]+] from ( select CONVERT ( varchar (ten), a.[startspecday],120) Startspecday,a.[leavename] from [test].[ DBO]. [View_getspday] As a ) as B
--Create XMLTableCreate TableXMLTable (Idint IDENTITY(1,1)Primary Key, xmlcol XML); Go ------------------------------------------------------------------------------------Insert XML Data SingleInsert into [XML].[dbo].[XMLTable] ([Xmlcol]) Select * from OpenRowset(BULK 'G:\Document\XMLDocument\x3.xml
)Untyped XML is not expressed in XML schema. It is saved as a Unicode string in SQL Server.
Storage. For their operations, data needs to be converted to the corresponding type. For example (/book/price) [1]> 19.99,
Decimal process. A large number of similar comparisons consume a lot of resources, which leads to the importance of type information in
Getting Started with SQL XML:--by jinjazz
1. xml: Ability to recognize elements, attributes, and values
2. XPath: addressing language, lookup similar to Windows directory (go to the wall if you don't use the dir command)
Syntax format, which can be combined as a condition:
"." Express oneself, "..." Said the father, "/" said the Son, "//" to indicate the offsprin
Copy CodeThe code is as follows:
/*01.
Introduction to 02.sql XML:
--by Jinjazz
--http://blog.csdn.net/jinjazz
25l
06.1, XML: Ability to recognize elements, attributes, and values
07.
08.2, XPath: Addressing language, lookup similar to Windows directory (go to the wall if you don't use the dir command)
09.
10. Syntax format, which can be combined as a condition:
the first book
SelectTab.Col.value ('(Book/title) [1]','varchar (max)') astitle from @data. Nodes ('Bookstore') asTab (Col)--16. Get the first author of each book
SelectTab.Col.value ('Author[1]','varchar (max)') astitle from @data. Nodes ('//book') asTab (Col)--17. Get all the information of all book
SelectT.c.value ('Title[1]','varchar (max)') astitle, T.c.val
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.