sqlxml

How to Update XML in SQL based on values in that XML

时光总嘲笑我的痴心妄想 提交于 2020-01-05 11:04:04
问题 I have to update XML of table based on some conditions of that XML. Sample XML: <CountryValues> <CountryRow> <CountryName>Brazil</CountryName> <PlaceName>Place 1</PlaceName> <Month>1</Month> <PlaceValue>0</PlaceValue> </CountryRow> <CountryRow> <CountryName>Brazil</CountryName> <PlaceName>Place 1</PlaceName> <Month>2</Month> <PlaceValue>0</PlaceValue> </CountryRow> <CountryRow> <CountryName>Brazil</CountryName> <PlaceName>Place 1</PlaceName> <Month>3</Month> <PlaceValue>0</PlaceValue> <

How do I clean up LOB values in Hibernate UserTypes?

耗尽温柔 提交于 2020-01-04 06:23:32
问题 I am running Oracle 11.2.0.3 and am attempting to create a workable UserType that maps XMLType or SQLXML columns. Existing solutions found online all have two problems: XMLType values are LOB values, so they must be free() prior to Connection.close() or they will leak both database resources and heap memory in Java. XML values fetched from these columns are connected objects; unless they are copied via a deep copy, they are gone after the connection closes. So, I wrote this classes at the

Bulk load XML referring to auto-increment parent-id

本秂侑毒 提交于 2020-01-04 02:34:12
问题 In short : I want to do an XML Bulk Load to a SQL Server (2008) database and generate auto-increment-id's for a parent, that can be used in the child. This seems limited by the scope: the parent-node is not finished, so not inserted yet. Does anybody know a way around this? The longer description (sorry, it's really long, but I try to be complete): From a customer I got a lot of XML-documents with a similar structure from which to generate a test-DB. They are exported for use by another tool,

How can I query a value in a XML column in SQL Server 2008

心不动则不痛 提交于 2019-12-25 04:30:05
问题 I have following XML stored in a XML column in a SQL Server database table. <?xml version="1.0" encoding="UTF-8" ?> <ns0:Root> <ns0:Result> <ns0:AStatus>Aaa</ns0:AStatus> <ns0:BStatus>Bbb</ns0:BStatus> </ns0:Result> </ns0:Root> I'd like to get value "Aaa", by firing SQL query. 回答1: Your XML data is incomplete - it uses a namespace prefix ns0 without defining it anywhere... I've added some arbitrary, totally made-up XML namespace here in my sample - you need to check what that XML namespace

FOR XML multiple control by attribute in tree concept

风流意气都作罢 提交于 2019-12-25 02:38:17
问题 I want to figure out one issue. I already had question about simple ordering issue but I want to order more detail. check below this link : SQL Server : FOR XML sorting control by attribute I made a example case. SQL Query. select ( select '123' AS '@id', ( select ( select 'test' AS '@testid' , '20' AS '@order' FOR XML path ('tree') , TYPE ), ( select 'test2' AS '@testid' , '30' AS '@order' FOR XML path ('tree-order') , TYPE ), ( select 'test' AS '@testid' , '10' AS '@order' FOR XML path (

How to query the xml in SQL XML on a SQL Server 2008 database

╄→尐↘猪︶ㄣ 提交于 2019-12-25 01:44:43
问题 I have a SQL Server 2008 database. There is a table called Documents with the following schema: Id int PK DocumentXml xml The xml documents all look something like: <docroot> <name>Some Name</name> </docroot> I want to select all the records where the text value of /docroot/name begins with an "S" (case-insenstive). How do I execute this query with the best performance? 回答1: Not sure about the performance - but you can do something like this: SELECT (list of columns) FROM dbo.Documents WHERE

xml query with more than one condition

心已入冬 提交于 2019-12-25 01:06:13
问题 It is my sql data : <ArrayOfFlowDetailParameters xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <FlowDetailParameters> <DepartmentId>23</DepartmentId> <UserId xsi:nil="true" /> <Username /> <FullName /> <ConfirmDateTime xsi:nil="true" /> <Comment /> <Status>Pending</Status> <AttachmentId /> </FlowDetailParameters> <FlowDetailParameters> <DepartmentId>22</DepartmentId> <UserId xsi:nil="true" /> <Username /> <FullName /> <ConfirmDateTime xsi

Why would a schema make an XML column slower?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 19:37:12
问题 I have a table with an XML column. The documents are pretty large and numerous, and I've been trying various ways to improve the performance of basic queries. Because the documentation indicates that applying an XML Schema to the column can help SQL Server to optimize queries — and because one was available — I created a schema collection and applied the type to my XML column. Query performance went off a cliff. I mean, the very simplest tests became intolerably slow. I removed the column

Xml select query xpath is slow

谁都会走 提交于 2019-12-24 17:28:56
问题 My XML structure: <Items> <Item> <guid>FC550573-7171-997F-752D-8D65590CBFD6</guid> <Objects> <Object> <type>0</type> <guid>E10D9DA9-2C8D-8024-2F07-DF21395811BF</guid> </Object> <Object> <type>0</type> <guid>D8338400-35C7-781E-A039-C0FDDF80714A</guid> </Object> </Objects> </Item> </Items> When filling the Objects Table: CREATE TABLE [dbo].[Objects]( [item_guid] [varchar](36) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [type] [int] NOT NULL, [guid] [varchar](36) COLLATE SQL_Latin1_General

Extracting nvarchar value from XML in T-SQL: only one character returned

天涯浪子 提交于 2019-12-24 15:15:42
问题 In my T-SQL procedure I'm trying to extract a string value from the XML node using the .value() method, like this: declare @criteria xml; set @criteria = N'<criterion id="DocName"><value>abcd</value></criterion>'; declare @val nvarchar; set @val = @criteria.value('(criterion[@id="DocName"]/value)[1]', 'nvarchar'); select @val; I expected to get 'abcd' as a result, but I surprisingly got just 'a' . So, the value method returns only the 1st character of the string. Can anybody tell me, what am