Querying a complexe XML column
Does anybody know how to query the table nf_xmlt (id number not null, xml_nucleo xmltype)
whose column xml_nucleo contains
<dati xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="">
<codiceinterno/>
<codicefiscaleassistito>CRBJNF92S70G628L</codicefiscaleassistito>
<famigliare>
<anagrafica>
<codiceinterno>352585</codiceinterno>
<codicefiscale>CRBRRT43R29G001M</codicefiscale>
<cognome>TARCISI</cognome>
<nome>ROBERTO</nome>
<sesso>M</sesso>
<datanascita>29/10/1943</datanascita>
<nazionalita>ITALIANA</nazionalita>
<dataingressouscita>06/12/1988</dataingressouscita>
<provenienzadestinazione>17029</provenienzadestinazione>
<codiceresidenzialita>0</codiceresidenzialita>
<comunedinascita>17121</comunedinascita>
<indirizzoresidenza>VIA F.LLI BANDIERA, 8</indirizzoresidenza>
<codiceistatresidenza>34027</codiceistatresidenza>
<capresidenza>43100</capresidenza>
<indirizzodomicilio/>
<codiceistatdomicilio/>
<capdomicilio/>
<datamorte/>
</anagrafica>
<rapportoparentela>I.S.</rapportoparentela>
</famigliare>
<famigliare>
<anagrafica>
<codiceinterno>352586</codiceinterno>
<codicefiscale>RNRCMN45L50A794R</codicefiscale>
<cognome>ZAMBELLI</cognome>
<nome>CARMEN</nome>
<sesso>F</sesso>
<datanascita>10/07/1945</datanascita>
<nazionalita>ITALIANA</nazionalita>
<dataingressouscita>06/12/1988</dataingressouscita>
<provenienzadestinazione>17029</provenienzadestinazione>
<codiceresidenzialita>0</codiceresidenzialita>
<comunedinascita>16024</comunedinascita>
<indirizzoresidenza>VIA F.LLI BANDIERA, 8</indirizzoresidenza>
<codiceistatresidenza>34027</codiceistatresidenza>
<capresidenza>43100</capresidenza>
<indirizzodomicilio/>
<codiceistatdomicilio/>
<capdomicilio/>
<datamorte/>
</anagrafica>
<rapportoparentela>MOGLIE</rapportoparentela>
</famigliare>
</dati>
in order to get:
a)
codiceinterno rapportoparentela
352585 I.S.
or
codiceinterno rapportoparentela
352586 MOGLIE
b) the sequence of the whole content of the nodes <anagrafica>
Thanks. Regards.
SQL> create table my_xml_table of xmltype
2 /
Table created.
SQL> insert into my_xml_table values
2 (
3 xmltype(
4 '<dati xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="">
5 <codiceinterno/>
6 <codicefiscaleassistito>CRBJNF92S70G628L</codicefiscaleassistito>
7 <famigliare>
8 <anagrafica>
9 <codiceinterno>352585</codiceinterno>
10 <codicefiscale>CRBRRT43R29G001M</codicefiscale>
11 <cognome>TARCISI</cognome>
12 <nome>ROBERTO</nome>
13 <sesso>M</sesso>
14 <datanascita>29/10/1943</datanascita>
15 <nazionalita>ITALIANA</nazionalita>
16 <dataingressouscita>06/12/1988</dataingressouscita>
17 <provenienzadestinazione>17029</provenienzadestinazione>
18 <codiceresidenzialita>0</codiceresidenzialita>
19 <comunedinascita>17121</comunedinascita>
20 <indirizzoresidenza>VIA F.LLI BANDIERA, 8</indirizzoresidenza>
21 <codiceistatresidenza>34027</codiceistatresidenza>
22 <capresidenza>43100</capresidenza>
23 <indirizzodomicilio/>
24 <codiceistatdomicilio/>
25 <capdomicilio/>
26 <datamorte/>
27 </anagrafica>
28 <rapportoparentela>I.S.</rapportoparentela>
29 </famigliare>
30 <famigliare>
31 <anagrafica>
32 <codiceinterno>352586</codiceinterno>
33 <codicefiscale>RNRCMN45L50A794R</codicefiscale>
34 <cognome>ZAMBELLI</cognome>
35 <nome>CARMEN</nome>
36 <sesso>F</sesso>
37 <datanascita>10/07/1945</datanascita>
38 <nazionalita>ITALIANA</nazionalita>
39 <dataingressouscita>06/12/1988</dataingressouscita>
40 <provenienzadestinazione>17029</provenienzadestinazione>
41 <codiceresidenzialita>0</codiceresidenzialita>
42 <comunedinascita>16024</comunedinascita>
43 <indirizzoresidenza>VIA F.LLI BANDIERA, 8</indirizzoresidenza>
44 <codiceistatresidenza>34027</codiceistatresidenza>
45 <capresidenza>43100</capresidenza>
46 <indirizzodomicilio/>
47 <codiceistatdomicilio/>
48 <capdomicilio/>
49 <datamorte/>
50 </anagrafica>
51 <rapportoparentela>MOGLIE</rapportoparentela>
52 </famigliare>
53 </dati>')
54 )
55 /
1 row created.
SQL> commit
2 /
Commit complete.
SQL> select extractValue(value(f),'/famigliare/rapportoparentela') rapportoparentela,
2 extractValue(value(f),'/famigliare/anagrafica/codiceinterno') codiceinterno
3 from my_xml_table, table(xmlsequence(extract(object_value,'/dati/famigliare'))) f
4 /
RAPPORTOPARENTELA
CODICEINTERNO
I.S.
352585
MOGLIE
352586
Similar Messages
-
Duplication in SELECT query with XML column
Oracle 11gR1 RHEL 5
Hi all,
I am having a small problem. I am selecting some rows from an XML column with the following query and for each row I get a new set of columns that are displayed.
select extractvalue(old_row,'/xml/WORK_ITEM_RID') WORK_ITEM_RID,
extractvalue(old_row,'/xml/PARENT_RID') PARENT_RID,
extractvalue(old_row,'/xml/ASSIGNED_TO') ASSIGNED_TO
from audit_trail
where audit_trail_rid = 177147;
So instead of getting this:
WORK_ITEM_RID PARENT_RID ASSIGNED_TO
4045 4044 2930
I get:
WORK_ITEM_RID PARENT_RID ASSIGNED_TO
4045
WORK_ITEM_RID PARENT_RID ASSIGNED_TO
4044
WORK_ITEM_RID PARENT_RID ASSIGNED_TO
2930
How can I get rid of this?
Thanks.
Edited by: JrOraDBA on Feb 12, 2010 10:14 AMHere is what I got so far...but it keeps telling me that I am missing right parenthesis (ORA-00907) at the assigned_date TO_CHAR(....
insert into iswrnew.WORK_ITEM (WORK_ITEM_RID, PARENT_RID, ASSIGNED_TO, WORK_ITEM_TYPE_RID, FPRC_APPLICATION_RID, REQUEST_RID, ASSIGNED_DATE, EST_START_DATE, EST_COMPLETION_DATE, SHORT_DESCRIPTION, ASSIGNED_BY, COMPLETED, COMPLETION_DATE, LONG_DESCRIPTION)
SELECT t1.work_item_rid, t1.parent_rid, t1.assigned_to, t1.work_item_type_rid, t1.fprc_application_rid, t1.request_rid, t1.assigned_date, t1.est_start_date, t1.est_completion_date, t1.short_description, t1.assigned_by, t1.completed, t1.completion_date, t1.long_description
FROM fprchr.audit_trail,
XMLTable('/xml'
PASSING fprchr.audit_trail.old_row
COLUMNS
work_item_rid NUMBER PATH 'WORK_ITEM_RID',
parent_rid NUMBER PATH 'PARENT_RID',
assigned_to NUMBER PATH 'ASSIGNED_TO',
work_item_type_rid NUMBER PATH 'WORK_ITEM_TYPE_RID',
fprc_application_rid NUMBER PATH 'FPRC_APPLICATION_RID',
request_rid NUMBER PATH 'REQUEST_RID',
*assigned_date TO_CHAR(assigned_date,'YYYY-MM-DD HH24:MI:SS') PATH 'ASSIGNED_DATE',*
est_start_date TO_CHAR(est_start_date,'YYYY-MM-DD HH24:MI:SS') PATH 'EST_START_DATE',
est_completion_date TO_CHAR(est_completion_date,'YYYY-MM-DD HH24:MI:SS') PATH 'EST_COMPLETION_DATE',
short_description VARCHAR2(50) PATH 'SHORT_DESCRIPTION',
assigned_by NUMBER PATH 'ASSIGNED_BY',
completed VARCHAR2(1) PATH 'COMPLETED',
completion_date TO_CHAR(completion_date,'YYYY-MM-DD HH24:MI:SS') PATH 'COMPLETION_DATE',
long_description VARCHAR2(4000) PATH 'LONG_DESCRIPTION') t1
WHERE audit_trail_rid = 177147;I think I'm missing something obvious but I just cannot see it. I need a fresh pair of eyes to look at this :)
Thanks for all your help -
Source table has an xml column that I need to query before splitting into 2 tables.
Hi
I have a source table with an xml column that I need to query on the nodes and then depending on what data is in the node then to split it into 2 different tables. I don't think I can use conditional split so I am looking at just a straight Execute SQL Task.
Has anyone got any ideas on any other way of doing this?
Thanks for the help in advance.
DaveHi TheDish,
Your goal arguably can me accomplished using pure T-SQL only encompassing XPath or XQuery.
E.g. the XQuery would retrieve the nodes as explained in http://sqljudo.wordpress.com/2013/12/02/xpath-for-the-sql-server-dba/
And then you may want to use the WHERE clause to extract - insert the nodes that go to one or another table.
I don't see why SSIS is necessary, but you can run the same queries in two Data Sources, or Execute SQL Tasks (that capture a resultset).
Arthur
MyBlog
Twitter -
Querying XML Column in SQL to get all attributes for a element
I have data in a XML column that is formatted as such:
<TestTemplate xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MTouch TabKey="20" Priority="0">
<MMouse MouseKey="21" Priority="0" /> </MTouch>
<MTouch TabKey="11" Priority="1" />
<MTouch TabKey="14" Priority="2" />
<MTouch TabKey="17" Priority="3" />
<MTouch TabKey="23" Priority="4">
<MCategories CatKey="8" Priority="0" />
<MMouse MouseKey="27" Priority="1" />
<MMouse MouseKey="30" Priority="2" />
<MMouse MouseKey="26" Priority="3" />
<MCategories CatKey="9" Priority="4" />
<MGroups GroupKey="3" Priority="5" />
<MMouse MouseKey="28" Priority="6" />
<MCategories CatKey="7" Priority="7" />
<MMouse MouseKey="29" Priority="8" />
</MTouch>
<MTouch TabKey="6" Priority="5">
</MTouch>
</TestTemplate>
In my query I am getting the following results :
ElementName
AttributeName
TabKey
CategoryKey
MTouch
MCategories
6
7
MTouch
MCategories
6
8
MTouch
MCategories
6
9
MTouch
MCategories
11
7
MTouch
MCategories
11
8
MTouch
MCategories
11
9
MTouch
MCategories
14
7
MTouch
MCategories
14
8
MTouch
MCategories
14
9
MTouch
MCategories
17
7
MTouch
MCategories
17
8
MTouch
MCategories
17
9
MTouch
MCategories
20
7
MTouch
MCategories
20
8
MTouch
MCategories
20
9
MTouch
MCategories
23
7
MTouch
MCategories
23
8
MTouch
MCategories
23
9
This is my query:
SELECT DISTINCT
'MTouch' AS ElementName,
'MCategories' AS AttributeName,
n.y.value('@TabKey', 'int') AS TabKey,
e.y.value('@CatKey', 'int') AS CategoryKey
FROM TXML cross apply tablename.columnname.nodes('//TestTemplate//MTouch//MCategories') AS e(y)
cross apply tablename.collumnname.nodes('//TestTemplate//MTouch') AS n(y)
I would like my results to show only the catkey attribute value to show only for MTouch TabKey 23. I need help on how to write the query. Below is the result I am looking for. Notice the Categorykey column is null for all except where
the Element Name of MTouch has a TabKey value of 23.
ElementName
AttributeName
TabKey
TouchPriority
CategoryKey
MTouch
MCategories
6
5
MTouch
MCategories
11
1
MTouch
MCategories
14
2
MTouch
MCategories
17
3
MTouch
MCategories
20
0
MTouch
MCategories
23
4
7
MTouch
MCategories
23
4
8
MTouch
MCategories
23
4
9
Thanks in advance
As per the this explanation
I would like my results to show only the catkey attribute value to show only for MTouch TabKey 23
it should be this
select
t.u.value('@TabKey[1]','int') AS tabKey,
t.u.value('@Priority[1]','int') AS Priority,
m.n.value('@CatKey[1]','int')
from @x.nodes('/TestTemplate/MTouch')t(u)
outer apply u.nodes('.[@TabKey="23"]/MCategories')m(n)
ORDER BY 1,3
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to insert fragment into xml column generated from query
I'm trying to generate xml from some relational data and then insert a sub node into an xml column. Here's some sample code that obviously doesn't work. I'm trying to figure out the syntax where the ???? exist.
/* create test tables*/
DECLARE @person TABLE
id int NOT NULL PRIMARY KEY CLUSTERED,
info xml NULL
DECLARE @roles TABLE
id int NOT NULL,
role_name varchar(20) NOT NULL,
PRIMARY KEY
id,
role_name
/* insert test values */
INSERT INTO @person (id, info)
VALUES (1, '<person><name><first_name>Joe</first_name><last_name>Smith</last_name></name></person>'),
(2, '<person><name><first_name>Tim</first_name><last_name>Jones</last_name></name></person>');
INSERT INTO @roles (id, role_name)
VALUES
(1,'Admin'),
(1,'User'),
(2,'Editor'),
(2,'User');
/* make sure that xml comes back correctly*/
SELECT
role_name AS name
FROM @roles AS role
WHERE id = 1 -- works for each id
FOR XML AUTO, ROOT ('roles');
UPDATE p
SET info.modify('insert ???? as last into (/person)[1]')
FROM @person p
INNER JOIN @roles r
ON p.id = r.id
/* desired output in the info column for id = 1*/
<person>
<name>
<first_name>Joe</first_name>
<last_name>Smith</last_name>
</name>
<roles>
<role name="Admin" />
<role name="User" />
</roles>
</person>
Any ideas?this?
DECLARE @person TABLE
id int NOT NULL PRIMARY KEY CLUSTERED,
info xml NULL
DECLARE @roles TABLE
id int NOT NULL,
role_name varchar(20) NOT NULL,
PRIMARY KEY
id,
role_name
/* insert test values */
INSERT INTO @person (id, info)
VALUES (1, '<person><name><first_name>Joe</first_name><last_name>Smith</last_name></name></person>'),
(2, '<person><name><first_name>Tim</first_name><last_name>Jones</last_name></name></person>');
INSERT INTO @roles (id, role_name)
VALUES
(1,'Admin'),
(1,'User'),
(2,'Editor'),
(2,'User');
/* make sure that xml comes back correctly*/
SELECT
role_name AS name
FROM @roles AS role
WHERE id = 1 -- works for each id
FOR XML AUTO, ROOT ('roles');
UPDATE p
SET info.modify('insert sql:column("x") as last into (/person)[1]')
FROM @person p
CROSS APPLY(SELECT role_name FROM @roles WHERE id = p.id FOR XML PATH(''),ROOT('roles'),TYPE)r(x)
select * from @person
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Complex xml with multiple namespaces giving LPX-00601: Invalid token error
Hi
Apologies if this is a really simple question.
I have not worked with xml before and I'm drowning in different ways to do the extract.
I have a very complex xml, sample below, which I'm trying to do one siple extract to get myself going.
I have the data in a table in an xmltype column,
I am trying to extract containernumber first and get the error.
select xml_column, extract(xml_column,'/env:Envelope/env:Body/ns0:QueryCntrNumberResponse/ns0:QueryResContainerDetail/ns1:ContainerNumber/ns2:ContainerNumber')
from test_xml;
Not sure if I should use the namespaces and have tried without but results are always NULL
I would really appreciate any pointers around these ultiple namespaces.
Thanks
Nicki
XML Sample
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns0="http://com.cargosmart.cargotracking.webservice.cntr.dto"
xmlns:ns1="http://com.cargosmart.cargotracking.webservice.common.dto"
xmlns:ns2="http://com.cargosmart.cargotracking.webservice.basic.dto"
xmlns:ns3="http://com.cargosmart.cargotracking.webservice.bl.dto"
xmlns:ns4="http://com.cargosmart.cargotracking.webservice.bkg.dto">
<env:Body>
<ns0:QueryByCntrNumberResponse>
<ns0:QueryRes ult="">
<ns0:QueryCriteria>
<ns1:CarrierSCACCode>APLU</ns1:CarrierSCACCode>
<ns1:ContainerNumber>APZU344693-1</ns1:ContainerNumber>
</ns0:QueryCriteria>
<ns0:ContainerDetail>
<ns1:ContainerNumber>
<ns2:ContainerNumber>APZU344693</ns2:ContainerNumber>
<ns2:ContainerCheckDigit>1</ns2:ContainerCheckDigit>
<ns2:GrossWeight>
<ns2:Weight>20260.8</ns2:Weight>
<ns2:WeightUnit>KGS</ns2:WeightUnit>
</ns2:GrossWeight>
</ns1:ContainerNumber>
NOT THE FULL COLUMNCould I just ask you one more question.
I had already expanded the query to include the repeating sections using xmlsequence.
Has that been replaced too?
select extractvalue(xml_column,'/env:Envelope/env:Body/ns0:QueryByCntrNumberResponse/ns0:QueryResult/ns0:ContainerDetail/ns1:ContainerNumber/ns2:ContainerNumber',
'xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns0="http://com.cargosmart.cargotracking.webservice.cntr.dto"
xmlns:ns1="http://com.cargosmart.cargotracking.webservice.common.dto"
xmlns:ns2="http://com.cargosmart.cargotracking.webservice.basic.dto"
xmlns:ns3="http://com.cargosmart.cargotracking.webservice.bl.dto"
xmlns:ns4="http://com.cargosmart.cargotracking.webservice.bkg.dto"') col1,
extractvalue(value(t2),'/ns1:Event/ns1:EventDescription', 'xmlns:ns1="http://com.cargosmart.cargotracking.webservice.common.dto"') Event_Description,
extractvalue(value(t2),'/ns1:Event/ns1:EventDT/ns2:LocDT', 'xmlns:ns1="http://com.cargosmart.cargotracking.webservice.common.dto" xmlns:ns2="http://com.cargosmart.cargotracking.webservice.basic.dto"') Event_DT,
extractvalue(value(t2),'/ns1:Event/ns1:Location/ns2:LocationName', 'xmlns:ns1="http://com.cargosmart.cargotracking.webservice.common.dto" xmlns:ns2="http://com.cargosmart.cargotracking.webservice.basic.dto"') location
from test_xml t1,
table(xmlsequence(extract(t1.xml_column,'/env:Envelope/env:Body/ns0:QueryByCntrNumberResponse/ns0:QueryResult/ns0:ContainerDetail/ns1:Event','xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns0="http://com.cargosmart.cargotracking.webservice.cntr.dto"
xmlns:ns1="http://com.cargosmart.cargotracking.webservice.common.dto"
xmlns:ns2="http://com.cargosmart.cargotracking.webservice.basic.dto"
xmlns:ns3="http://com.cargosmart.cargotracking.webservice.bl.dto"
xmlns:ns4="http://com.cargosmart.cargotracking.webservice.bkg.dto"'))) t2; -
Team , Thanks for looking into this ..
As a last resort on optimizing my stored procedure ( Below ) i wanted to create a Selective XML index ( Normal XML indexes doesn't seem to be improving performance as needed ) but i keep getting this error within my stored proc . Selective XML
Index feature is not supported for the current database version.. How ever
EXECUTE sys.sp_db_selective_xml_index; return 1 , stating Selective XML Indexes are enabled on my current database .
Is there ANY alternative way i can optimize below stored proc ?
Thanks in advance for your response(s) !
/****** Object: StoredProcedure [dbo].[MN_Process_DDLSchema_Changes] Script Date: 3/11/2015 3:10:42 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- EXEC [dbo].[MN_Process_DDLSchema_Changes]
ALTER PROCEDURE [dbo].[MN_Process_DDLSchema_Changes]
AS
BEGIN
SET NOCOUNT ON --Does'nt have impact ( May be this wont on SQL Server Extended events session's being created on Server(s) , DB's )
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
select getdate() as getdate_0
DECLARE @XML XML , @Prev_Insertion_time DATETIME
-- Staging Previous Load time for filtering purpose ( Performance optimize while on insert )
SET @Prev_Insertion_time = (SELECT MAX(EE_Time_Stamp) FROM dbo.MN_DDLSchema_Changes_log ) -- Perf Optimize
-- PRINT '1'
CREATE TABLE #Temp
EventName VARCHAR(100),
Time_Stamp_EE DATETIME,
ObjectName VARCHAR(100),
ObjectType VARCHAR(100),
DbName VARCHAR(100),
ddl_Phase VARCHAR(50),
ClientAppName VARCHAR(2000),
ClientHostName VARCHAR(100),
server_instance_name VARCHAR(100),
ServerPrincipalName VARCHAR(100),
nt_username varchar(100),
SqlText NVARCHAR(MAX)
CREATE TABLE #XML_Hold
ID INT NOT NULL IDENTITY(1,1) PRIMARY KEY , -- PK necessity for Indexing on XML Col
BufferXml XML
select getdate() as getdate_01
INSERT INTO #XML_Hold (BufferXml)
SELECT
CAST(target_data AS XML) AS BufferXml -- Buffer Storage from SQL Extended Event(s) , Looks like there is a limitation with xml size ?? Need to re-search .
FROM sys.dm_xe_session_targets xet
INNER JOIN sys.dm_xe_sessions xes
ON xes.address = xet.event_session_address
WHERE xes.name = 'Capture DDL Schema Changes' --Ryelugu : 03/05/2015 Session being created withing SQL Server Extended Events
--RETURN
--SELECT * FROM #XML_Hold
select getdate() as getdate_1
-- 03/10/2015 RYelugu : Error while creating XML Index : Selective XML Index feature is not supported for the current database version
CREATE SELECTIVE XML INDEX SXI_TimeStamp ON #XML_Hold(BufferXml)
FOR
PathTimeStamp ='/RingBufferTarget/event/timestamp' AS XQUERY 'node()'
--RETURN
--CREATE PRIMARY XML INDEX [IX_XML_Hold] ON #XML_Hold(BufferXml) -- Ryelugu 03/09/2015 - Primary Index
--SELECT GETDATE() AS GETDATE_2
-- RYelugu 03/10/2015 -Creating secondary XML index doesnt make significant improvement at Query Optimizer , Instead creation takes more time , Only primary should be good here
--CREATE XML INDEX [IX_XML_Hold_values] ON #XML_Hold(BufferXml) -- Ryelugu 03/09/2015 - Primary Index , --There should exists a Primary for a secondary creation
--USING XML INDEX [IX_XML_Hold]
---- FOR VALUE
-- --FOR PROPERTY
-- FOR PATH
--SELECT GETDATE() AS GETDATE_3
--PRINT '2'
-- RETURN
SELECT GETDATE() GETDATE_3
INSERT INTO #Temp
EventName ,
Time_Stamp_EE ,
ObjectName ,
ObjectType,
DbName ,
ddl_Phase ,
ClientAppName ,
ClientHostName,
server_instance_name,
nt_username,
ServerPrincipalName ,
SqlText
SELECT
p.q.value('@name[1]','varchar(100)') AS eventname,
p.q.value('@timestamp[1]','datetime') AS timestampvalue,
p.q.value('(./data[@name="object_name"]/value)[1]','varchar(100)') AS objectname,
p.q.value('(./data[@name="object_type"]/text)[1]','varchar(100)') AS ObjectType,
p.q.value('(./action[@name="database_name"]/value)[1]','varchar(100)') AS databasename,
p.q.value('(./data[@name="ddl_phase"]/text)[1]','varchar(100)') AS ddl_phase,
p.q.value('(./action[@name="client_app_name"]/value)[1]','varchar(100)') AS clientappname,
p.q.value('(./action[@name="client_hostname"]/value)[1]','varchar(100)') AS clienthostname,
p.q.value('(./action[@name="server_instance_name"]/value)[1]','varchar(100)') AS server_instance_name,
p.q.value('(./action[@name="nt_username"]/value)[1]','varchar(100)') AS nt_username,
p.q.value('(./action[@name="server_principal_name"]/value)[1]','varchar(100)') AS serverprincipalname,
p.q.value('(./action[@name="sql_text"]/value)[1]','Nvarchar(max)') AS sqltext
FROM #XML_Hold
CROSS APPLY BufferXml.nodes('/RingBufferTarget/event')p(q)
WHERE -- Ryelugu 03/05/2015 - Perf Optimize - Filtering the Buffered XML so as not to lookup at previoulsy loaded records into stage table
p.q.value('@timestamp[1]','datetime') >= ISNULL(@Prev_Insertion_time ,p.q.value('@timestamp[1]','datetime'))
AND p.q.value('(./data[@name="ddl_phase"]/text)[1]','varchar(100)') ='Commit' --Ryelugu 03/06/2015 - Every Event records a begin version and a commit version into Buffer ( XML ) we need the committed version
AND p.q.value('(./data[@name="object_type"]/text)[1]','varchar(100)') <> 'STATISTICS' --Ryelugu 03/06/2015 - May be SQL Server Internally Creates Statistics for #Temp tables , we do not want Creation of STATISTICS Statement to be logged
AND p.q.value('(./data[@name="object_name"]/value)[1]','varchar(100)') NOT LIKE '%#%' -- Any stored proc which creates a temp table within it Extended Event does capture this creation statement SQL as well , we dont need it though
AND p.q.value('(./action[@name="client_app_name"]/value)[1]','varchar(100)') <> 'Replication Monitor' --Ryelugu : 03/09/2015 We do not want any records being caprutred by Replication Monitor ??
SELECT GETDATE() GETDATE_4
-- SELECT * FROM #TEMP
-- SELECT COUNT(*) FROM #TEMP
-- SELECT GETDATE()
-- RETURN
-- PRINT '3'
--RETURN
INSERT INTO [dbo].[MN_DDLSchema_Changes_log]
[UserName]
,[DbName]
,[ObjectName]
,[client_app_name]
,[ClientHostName]
,[ServerName]
,[SQL_TEXT]
,[EE_Time_Stamp]
,[Event_Name]
SELECT
CASE WHEN T.nt_username IS NULL OR LEN(T.nt_username) = 0 THEN t.ServerPrincipalName
ELSE T.nt_username
END
,T.DbName
,T.objectname
,T.clientappname
,t.ClientHostName
,T.server_instance_name
,T.sqltext
,T.Time_Stamp_EE
,T.eventname
FROM
#TEMP T
/** -- RYelugu 03/06/2015 - Filters are now being applied directly while retrieving records from BUFFER or on XML
-- Ryelugu 03/15/2015 - More filters are likely to be added on further testing
WHERE ddl_Phase ='Commit'
AND ObjectType <> 'STATISTICS' --Ryelugu 03/06/2015 - May be SQL Server Internally Creates Statistics for #Temp tables , we do not want Creation of STATISTICS Statement to be logged
AND ObjectName NOT LIKE '%#%' -- Any stored proc which creates a temp table within it Extended Event does capture this creation statement SQL as well , we dont need it though
AND T.Time_Stamp_EE >= @Prev_Insertion_time --Ryelugu 03/05/2015 - Performance Optimize
AND NOT EXISTS ( SELECT 1 FROM [dbo].[MN_DDLSchema_Changes_log] MN
WHERE MN.[ServerName] = T.server_instance_name -- Ryelugu Server Name needes to be added on to to xml ( Events in session )
AND MN.[DbName] = T.DbName
AND MN.[Event_Name] = T.EventName
AND MN.[ObjectName]= T.ObjectName
AND MN.[EE_Time_Stamp] = T.Time_Stamp_EE
AND MN.[SQL_TEXT] =T.SqlText -- Ryelugu 03/05/2015 This is a comparision Metric as well , But needs to decide on
-- Peformance Factor here , Will take advise from Lance if comparision on varchar(max) is a vital idea
--SELECT GETDATE()
--PRINT '4'
--RETURN
SELECT
top 100
[EE_Time_Stamp]
,[ServerName]
,[DbName]
,[Event_Name]
,[ObjectName]
,[UserName]
,[SQL_TEXT]
,[client_app_name]
,[Created_Date]
,[ClientHostName]
FROM
[dbo].[MN_DDLSchema_Changes_log]
ORDER BY [EE_Time_Stamp] desc
-- select getdate()
-- ** DELETE EVENTS after logging into Physical table
-- NEED TO Identify if this @XML can be updated into physical system table such that previously loaded events are left untoched
-- SET @XML.modify('delete /event/class/.[@timestamp="2015-03-06T13:01:19.020Z"]')
-- SELECT @XML
SELECT GETDATE() GETDATE_5
END
GO
Rajkumar Yelugu@@Version : ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2012 - 11.0.5058.0 (X64)
May 14 2014 18:34:29
Copyright (c) Microsoft Corporation
Developer Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
(1 row(s) affected)
Compatibility level is set to 110 .
One of the limitation states - XML columns with a depth of more than 128 nested nodes
How do i verify this ? Thanks .
Rajkumar Yelugu -
Need help getting a value from an XML column
Hi,
I need to get a value from an XML column in a table (the column is called TEST_XML). I have tried using the Select TEST_XML.value function but it always returns nulls. Could you please take a look at the following xml sample stored in the TEST_XML column
and help me with the query syntax to get the value of the Bank_Account_Number?.
=================
<?mso-infoPathSolution PIVersion="1.0.0.0" href="http://aaa.bbb.ccc.org/OF/PublicDownload.aspx/6bba49274b494ddcb005512670a5e214.xsn" name="urn:schemas-microsoft-com:office:infopath:BPIP-xsn:OF-Messages-Schemas-OF-Forms" language="en-us"
productVersion="14.0.0" solutionVersion="3.0.29.90" ?>
<?mso-application progid="InfoPath.Document"?>
<tns:OF_Forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="OF_Messages.Schemas.OF_Forms" xmlns:xdServerInfo="http://schemas.microsoft.com/office/infopath/2009/xslt/ServerInfo" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-07-22T10:58:18"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
<Name />
<Description />
<Settings Name="FormName" Description="Request for new master data.xml" SCE_RouteID="54" ROU_Name="IBP-Group" SCE_FunctionalAreaID="1" FUA_FunctionalAreaName="Data Maintenance" SCE_SchemaCategory="BP"
SCE_SchemaGUID="3c9b391c-26a1-46ec-a202-434453a6e582" SCE_FormGUID="6bba4927-4b49-4ddc-b005-512670a5e214" SCE_InstanceGUID="39595" SCE_SPInstancePath="" FIN_StaffID="" FirstName="" LastName=""
MAIL_SendBy="[email protected]" MAIL_Date="Thu, 12 Jun 2014 14:49:26 +0200" DateRequired="" MissingFields="" NewLine="
" SCE_RequestorAuthorizationMode="1" SCE_AllowSubmissionFromAll="1"
/>
<Init_Information>
<Date_Required xsi:nil="true" />
</Init_Information>
<General_Data>
<Action>U</Action>
<Business_Partner_Number xsi:nil="true" />
<Business_Partner_Grouping>G16</Business_Partner_Grouping>
<Business_Partner_Type>G003</Business_Partner_Type>
<Title>002</Title>
<House_Number xsi:nil="true" />
<Street xsi:nil="true" />
<Street_2 xsi:nil="true" />
<Street_3 xsi:nil="true" />
<City>ABIDJAN</City>
<Country>CI</Country>
<City_Postal_Code xsi:nil="true" />
<Region xsi:nil="true" />
<PO_Box xsi:nil="true" />
<PO_Box_Postal_Code xsi:nil="true" />
<Language>FR</Language>
<Purpose>Z003 UNVs</Purpose>
<Telephone_Number />
<Mobile_Phone_Number>90075777</Mobile_Phone_Number>
<Fax_Number xsi:nil="true" />
<Email_Address>[email protected]</Email_Address>
<First_Name>Mickey</First_Name>
<Middle_Name xsi:nil="true" />
<Last_Name>Mouse</Last_Name>
<Gender>2</Gender>
<Index_Number>999999</Index_Number>
<Date_of_Birth>1969-11-29</Date_of_Birth>
<Nationality>CI</Nationality>
<DOB_Day>29</DOB_Day>
<DOB_Month>11</DOB_Month>
<DOB_Year>1969</DOB_Year>
<RelationBPGroupingBPType xsi:nil="true" />
<BPType_Z016>Z003</BPType_Z016>
<BPType_Z020 xsi:nil="true" />
<BPType_Z021 xsi:nil="true" />
<Sub_Area2>General and Banking</Sub_Area2>
<SR_Description>Business Partner Number:
Business Partner Type: UNVs
First Name: FirstName
Last Name: LastName</SR_Description>
<Sub_Area_Aux>79</Sub_Area_Aux>
<thereis_general>TRUE</thereis_general>
<thereis_banking>TRUE</thereis_banking>
<auxGeneric>GDB</auxGeneric>
<Business_Area_BP>P022</Business_Area_BP>
<Search_Term_1>FirstName</Search_Term_1>
<Search_Term_2>LastName</Search_Term_2>
<Responsible_Institution xsi:nil="true" />
<Add_Additional_Address xsi:nil="true" />
<Add_Additional_Communication xsi:nil="true" />
<BP_Role_Main xsi:nil="true" />
<BP_Role_Additional xsi:nil="true" />
<AddresType xsi:nil="true" />
<Specify xsi:nil="true" />
<BP_Category xsi:nil="true" />
<AddRemoveAddress xsi:nil="true" />
<AddRemoveCommunication xsi:nil="true" />
<BusinessAreaOfBP_Aux>MALI</BusinessAreaOfBP_Aux>
</General_Data>
<Primary_Bank_Account>
<Bank_Location_ID>0001</Bank_Location_ID>
<Bank_Country>ML</Bank_Country>
<Bank_Account_Number>XXXX999888777666555444-00</Bank_Account_Number>
<Bank_Account_Type>1</Bank_Account_Type>
<IBAN xsi:nil="true" />
<CurrencyPrimaryIBAN xsi:nil="true" />
<Account_Holder_Name xsi:nil="true" />
<CurrencyOPrimaryNationalBankAccount>XOF</CurrencyOPrimaryNationalBankAccount>
<Routing_Number_x002F__National_ID>BDMAMLBA</Routing_Number_x002F__National_ID>
<NonIbanAccountHolderName>BANKNAME</NonIbanAccountHolderName>
<NonIbanBankAccountNumber>TESTNIBAN</NonIbanBankAccountNumber>
<CurrencyOPrimaryBankAccountNonIBAN>XOF</CurrencyOPrimaryBankAccountNonIBAN>
<NonIbanPrimaryBankAccountType>1</NonIbanPrimaryBankAccountType>
<NonIbanPrimaryAccountNameOfBank>BANK OF AFRICA</NonIbanPrimaryAccountNameOfBank>
<NonIbanPrimaryAccountBankAddressHouseNumber>CDCI</NonIbanPrimaryAccountBankAddressHouseNumber>
<NonIbanPrimaryAccountBankAddressStreet>DALOA, COMMERCE</NonIbanPrimaryAccountBankAddressStreet>
<NonIbanPrimaryAccountBankAddressCity>DALOA</NonIbanPrimaryAccountBankAddressCity>
<NonIbanPrimaryAccountBankAddressRegion>DALOA</NonIbanPrimaryAccountBankAddressRegion>
<NonIbanPrimaryAccountBankAddressPostalCode>+225</NonIbanPrimaryAccountBankAddressPostalCode>
<Primary_Type_of_Account xsi:nil="true" />
<invisible1>National ID</invisible1>
<bDontHasBankAccount>false</bDontHasBankAccount>
<bBankAccountNotAvailable>false</bBankAccountNotAvailable>
<CashOrCheck xsi:nil="true" />
<CashAccountingClerk xsi:nil="true" />
<BankID_BIC_SWIFT>BIBS</BankID_BIC_SWIFT>
<CheckOptions xsi:nil="true" />
<SameOrDifferent_IBAN_Primary xsi:nil="true" />
<SameOrDifferent_National_Primary xsi:nil="true" />
<SameOrDifferent_NotIBAN_Primary>Yes</SameOrDifferent_NotIBAN_Primary>
<AccountTitle_IBAN_Primary xsi:nil="true" />
<AccountTitle_National_Primary xsi:nil="true" />
<AccountTitle_NotIBAN_Primary xsi:nil="true" />
<ExplainWhy_IBAN_Primary xsi:nil="true" />
<ExplainWhy_National_Primary xsi:nil="true" />
<ExplainWhy_NotIBAN_Primary xsi:nil="true" />
<Bank_Key xsi:nil="true" />
<Bank_Control_Key xsi:nil="true" />
<Special_Instructions_IBAN_Primary xsi:nil="true" />
<Special_Instructions_National_Primary xsi:nil="true" />
<Special_Instructions_NotIBAN_Primary xsi:nil="true" />
<RecordTypePrimary xsi:nil="true" />
<Payment_Method_UnderCashCheck xsi:nil="true" />
<ValidUntilPrimaryBank xsi:nil="true" />
</Primary_Bank_Account>
<Primary_Intermediary_Bank_Account>
<Intermediary_Bank_Location_ID xsi:nil="true" />
<Intermediary_Bank_Country xsi:nil="true" />
<Intermediary_Bank_Account_Number xsi:nil="true" />
<Intermediary_Bank_Account_Type xsi:nil="true" />
<Intermediary_IBAN xsi:nil="true" />
<CurrencyIntermediaryIBAN xsi:nil="true" />
<Intermediary_Account_Holder_Name xsi:nil="true" />
<CurrencyOIntermediaryNationalBankAccount xsi:nil="true" />
<Intermediary_Routing_Number_National_ID xsi:nil="true" />
<IntermediaryNonIbanAccountHolderName xsi:nil="true" />
<IntermediaryNonIbanBankAccountNumber xsi:nil="true" />
<CurrencyOIntermediaryBankAccountNonIBAN xsi:nil="true" />
<NonIbanIntermediaryBankAccountType xsi:nil="true" />
<NonIbanIntermediaryAccountNameOfBank xsi:nil="true" />
<NonIbanIntermediaryAccountBankAddressHouseNumber xsi:nil="true" />
<NonIbanIntermediaryAccountBankAddressStreet xsi:nil="true" />
<NonIbanIntermediaryAccountBankAddressCity xsi:nil="true" />
<NonIbanIntermediaryAccountBankAddressRegion xsi:nil="true" />
<NonIbanIntermediaryAccountBankAddressPostalCode xsi:nil="true" />
<IntermediaryBankAccountVisible xsi:nil="true" />
<Intermediary_Type_of_Account xsi:nil="true" />
<invisible2 xsi:nil="true" />
<Intermediary_BankID_BIC_SWIFT_code xsi:nil="true" />
<SameOrDifferent_IBAN_Intermediary xsi:nil="true" />
<SameOrDifferent_National_Intermediary xsi:nil="true" />
<SameOrDifferent_NotIBAN_Intermediary xsi:nil="true" />
<AccountTitle_IBAN_Intermediary xsi:nil="true" />
<AccountTitle_National_Intermediary xsi:nil="true" />
<AccountTitle_NotIBAN_Intermediary xsi:nil="true" />
<ExplainWhy_IBAN_Intermediary xsi:nil="true" />
<ExplainWhy_National_Intermediary xsi:nil="true" />
<ExplainWhy_NotIBAN_Intermediary xsi:nil="true" />
</Primary_Intermediary_Bank_Account>
<Additional_Bank_Account>
<Additional_Bank_Location_ID xsi:nil="true" />
<Additional_Bank_Country xsi:nil="true" />
<Additional_Bank_Account_Number xsi:nil="true" />
<Additional_Bank_Account_Type xsi:nil="true" />
<Additional_IBAN xsi:nil="true" />
<CurrencyAdditionalIBAN xsi:nil="true" />
<Additional_Account_Holder_Name xsi:nil="true" />
<CurrencyOAdditionalNationalBankAccount xsi:nil="true" />
<Additional_Routing_Number_x002F__National_ID xsi:nil="true" />
<AdditionalNonIbanAccountHolderName xsi:nil="true" />
<AdditionalNonIbanBankAccountNumber xsi:nil="true" />
<CurrencyOAdditionalBankAccountNonIBAN xsi:nil="true" />
<NonIbanAdditionalBankAccountType xsi:nil="true" />
<NonIbanAdditionalAccountNameOfBank xsi:nil="true" />
<NonIbanAdditionalAccountBankAddressHouseNumber xsi:nil="true" />
<NonIbanAdditionalAccountBankAddressStreet xsi:nil="true" />
<NonIbanAdditionalAccountBankAddressCity xsi:nil="true" />
<NonIbanAdditionalAccountBankAddressRegion xsi:nil="true" />
<NonIbanAdditionalAccountBankAddressPostalCode xsi:nil="true" />
<AdditionalBankAccountVisible xsi:nil="true" />
<Additional_Type_of_Account xsi:nil="true" />
<invisible3 xsi:nil="true" />
<Additional_BankID_BIC_SWIFT_code xsi:nil="true" />
<SameOrDifferent_IBAN_Additional xsi:nil="true" />
<SameOrDifferent_National_Additional xsi:nil="true" />
<SameOrDifferent_NotIBAN_Additional xsi:nil="true" />
<AccountTitle_IBAN_Additional xsi:nil="true" />
<AccountTitle_National_Additional xsi:nil="true" />
<AccountTitle_NotIBAN_Additional xsi:nil="true" />
<ExplainWhy_IBAN_Additional xsi:nil="true" />
<ExplainWhy_National_Additional xsi:nil="true" />
<ExplainWhy_NotIBAN_Additional xsi:nil="true" />
<Additional_Bank_Key xsi:nil="true" />
<Additional_Bank_Control_Key xsi:nil="true" />
<Special_Instructions_IBAN_Additional xsi:nil="true" />
<Special_Instructions_National_Additional xsi:nil="true" />
<Special_Instructions_NotIBAN_Additional xsi:nil="true" />
<RecordTypeAdditional xsi:nil="true" />
<ValidUntilAdditionalBank xsi:nil="true" />
</Additional_Bank_Account>
<Payment_Information>
<Block_for_payment>1</Block_for_payment>
<Payment_Method xsi:nil="true" />
<Accounting_Clerk xsi:nil="true" />
<PaymentMethodAdditional xsi:nil="true" />
<AccountingClerkAdditional xsi:nil="true" />
</Payment_Information>
<Additional_Field_for_Purchasing_view>
<Purchase_order_currency>XOF</Purchase_order_currency>
<BP_Role_for_Screen_Usage__x0028_Real_State_x0029_ xsi:nil="true" />
<Central_Block_for_Business_Partner>false</Central_Block_for_Business_Partner>
<Posting_block_for_company_code xsi:nil="true" />
<Deletion_Flag_for_Master_Record__x0028_Company_Code_Leve xsi:nil="true" />
<Purchasing_block_at_purchasing_organization_level xsi:nil="true" />
<Deletion_flag_for_vendor_at_purchasing_level xsi:nil="true" />
<BPRoleDateBegin xsi:nil="true" />
<BPRoleDateEnd xsi:nil="true" />
</Additional_Field_for_Purchasing_view>
<Requestor_Information>
<Requested_By>REQUESTOR</Requested_By>
<Org_Unit>MVCON</Org_Unit>
<Date>2014-05-19</Date>
<Reason xsi:nil="true" />
<On_Form xsi:nil="true" />
<Attached xsi:nil="true" />
<Located_In_x002F_At>TIMBUKTOU</Located_In_x002F_At>
<RequestorBusinessArea>P022</RequestorBusinessArea>
<RequestorBusinessAreaValue>MALI</RequestorBusinessAreaValue>
<Display_Review_Approval_Section xsi:nil="true" />
</Requestor_Information>
<Review_Information>
<Review_By xsi:nil="true" />
<Org_Unit xsi:nil="true" />
<Date xsi:nil="true" />
</Review_Information>
<Approval_Information>
<Approved_By xsi:nil="true" />
<Org_Unit xsi:nil="true" />
<Date xsi:nil="true" />
</Approval_Information>
<Reception_Information>
<Received_By xsi:nil="true" />
<Org_Unit xsi:nil="true" />
<Date xsi:nil="true" />
</Reception_Information>
<Entry_Information>
<Entered_By xsi:nil="true" />
<Org_Unit xsi:nil="true" />
<Date xsi:nil="true" />
</Entry_Information>
<Verification_Information>
<Verified_By xsi:nil="true" />
<Org_Unit xsi:nil="true" />
<Date xsi:nil="true" />
</Verification_Information>
<Order_Currency>
<Order_Currency_New xsi:nil="true" />
</Order_Currency>
<Change_BP_Group>
<BP_Group_Existing xsi:nil="true" />
<BP_Type_Existing xsi:nil="true" />
<BP_Role_Existing xsi:nil="true" />
<BP_Group_New xsi:nil="true" />
<BP_Type_New xsi:nil="true" />
<BP_Role_New xsi:nil="true" />
<BPTypeAuxVisible1 xsi:nil="true" />
<BPTypeAuxVisible2 xsi:nil="true" />
</Change_BP_Group>
<Expire_or_Add_Validity_Period_to_BP_Role>
<Additional_BP_Role_Entry xsi:nil="true" />
</Expire_or_Add_Validity_Period_to_BP_Role>
<Add_Alternative_Payees>
<Additional_Payee xsi:nil="true" />
</Add_Alternative_Payees>
<Establish_BP_Relationship>
<Additional_Relationship_EntryB xsi:nil="true" />
</Establish_BP_Relationship>
<Block_BP>
<PaymentBlock xsi:nil="true" />
<Reason_Payment_Block xsi:nil="true" />
<PostingBlock xsi:nil="true" />
<Reason_Posting_Block xsi:nil="true" />
<PurchasingBlock xsi:nil="true" />
<Reason_Purchasing_Block xsi:nil="true" />
<CentralBlock xsi:nil="true" />
<Reason_Central_Block xsi:nil="true" />
<FlagforArchiving xsi:nil="true" />
<Reason_Flag_Block xsi:nil="true" />
<TerminateBP xsi:nil="true" />
<Reason_Terminate_Block xsi:nil="true" />
</Block_BP>
<Options>
<Option1>true</Option1>
<Option2>false</Option2>
<Option3>true</Option3>
<Option4>false</Option4>
<Option5>false</Option5>
<Option6>false</Option6>
<Option7>false</Option7>
<Option8>false</Option8>
<Opt_Update_BP_legal_Name>false</Opt_Update_BP_legal_Name>
</Options>
<Sec_Update_BP_Legal_Name>
<NewLegalFirstName xsi:nil="true" />
<NewLegalMiddleName xsi:nil="true" />
<NewLegalLastName xsi:nil="true" />
</Sec_Update_BP_Legal_Name>
<line>
<IDType>
<IDType xsi:nil="true" />
<LegacyIDNumber xsi:nil="true" />
<Responsible_Institution_Legacy xsi:nil="true" />
<AddRemoveID_R xsi:nil="true" />
</IDType>
</line>
<Address>
<Section_Address>
<AddressTypeR xsi:nil="true" />
<StreetR xsi:nil="true" />
<StreetR_2 xsi:nil="true" />
<StreetR_3 xsi:nil="true" />
<House_NumberR xsi:nil="true" />
<City_Postal_CodeR xsi:nil="true" />
<CityR xsi:nil="true" />
<CountryR xsi:nil="true" />
<StateRegionProvinceR xsi:nil="true" />
<PO_BoxR xsi:nil="true" />
<PO_Box_PostalCodeR xsi:nil="true" />
<SpecifyR xsi:nil="true" />
<AddRemoveAddressR xsi:nil="true" />
</Section_Address>
<PO_BoxR2>
<SecPoBoxR2>
<PO_BoxR2 xsi:nil="true" />
<PO_Box_Postal_CodeR2 xsi:nil="true" />
</SecPoBoxR2>
</PO_BoxR2>
</Address>
<Communication>
<Communication_Section>
<Telephone_NumberR xsi:nil="true" />
<Mobile_Phone_NumberR xsi:nil="true" />
<Fax_NumberR xsi:nil="true" />
<Email_AddressR xsi:nil="true" />
<AddRemoveCommunicationR xsi:nil="true" />
</Communication_Section>
</Communication>
<Expire_or_Add_Validaty_to_BP_RoleR>
<Expire_or_Add_Validaty>
<BP_RoleR xsi:nil="true" />
<Expire_or_Add_Validity_PeriodR xsi:nil="true" />
<Valid_FromR xsi:nil="true" />
<Valid_ToR xsi:nil="true" />
</Expire_or_Add_Validaty>
</Expire_or_Add_Validaty_to_BP_RoleR>
<Add_Alternative_PayeesR>
<Alternative_Payees>
<Add_Update_Remove xsi:nil="true" />
<Permited_Payee_BP_NumberR xsi:nil="true" />
<Name_Alt_PayeeR xsi:nil="true" />
<Index_NumberR xsi:nil="true" />
<TitleR xsi:nil="true" />
<First_NameR xsi:nil="true" />
<Middle_NameR xsi:nil="true" />
<Last_NameR xsi:nil="true" />
</Alternative_Payees>
</Add_Alternative_PayeesR>
<Establish_BP_RelationshipR>
<Relationship>
<BP_Number_Main xsi:nil="true" />
<Relationship_CategoryR xsi:nil="true" />
<ValidFromR xsi:nil="true" />
<ValidToRelationshipR xsi:nil="true" />
<BPNumber_SecondaryR xsi:nil="true" />
<Index_Number_Secondary_Relationship xsi:nil="true" />
<Business_Area_Secondary xsi:nil="true" />
<Title_Secondary_BP xsi:nil="true" />
<First_Name_Secondary_BPR xsi:nil="true" />
<MiddleNameSecondaryBPR xsi:nil="true" />
<LastNameSecondaryBP xsi:nil="true" />
<Add_Update_DeleteR xsi:nil="true" />
</Relationship>
</Establish_BP_RelationshipR>
<PO_BoxR>
<SecPoBoxR>
<PO_BoxR xsi:nil="true" />
<PO_Box_Postal_CodeR xsi:nil="true" />
</SecPoBoxR>
</PO_BoxR>
</tns:OF_Forms>See this illustration
declare @x xml='<?mso-infoPathSolution PIVersion="1.0.0.0" href="http://aaa.bbb.ccc.org/OF/PublicDownload.aspx/6bba49274b494ddcb005512670a5e214.xsn" name="urn:schemas-microsoft-com:office:infopath:BPIP-xsn:OF-Messages-Schemas-OF-Forms" language="en-us" productVersion="14.0.0" solutionVersion="3.0.29.90" ?>
<?mso-application progid="InfoPath.Document"?>
<tns:OF_Forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="OF_Messages.Schemas.OF_Forms" xmlns:xdServerInfo="http://schemas.microsoft.com/office/infopath/2009/xslt/ServerInfo" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-07-22T10:58:18" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
<Name />
<Description />
<Settings Name="FormName" Description="Request for new master data.xml" SCE_RouteID="54" ROU_Name="IBP-Group" SCE_FunctionalAreaID="1" FUA_FunctionalAreaName="Data Maintenance" SCE_SchemaCategory="BP" SCE_SchemaGUID="3c9b391c-26a1-46ec-a202-434453a6e582" SCE_FormGUID="6bba4927-4b49-4ddc-b005-512670a5e214" SCE_InstanceGUID="39595" SCE_SPInstancePath="" FIN_StaffID="" FirstName="" LastName="" MAIL_SendBy="[email protected]" MAIL_Date="Thu, 12 Jun 2014 14:49:26 +0200" DateRequired="" MissingFields="" NewLine="
" SCE_RequestorAuthorizationMode="1" SCE_AllowSubmissionFromAll="1" />
<Init_Information>
<Date_Required xsi:nil="true" />
</Init_Information>
<General_Data>
<Action>U</Action>
<Business_Partner_Number xsi:nil="true" />
<Business_Partner_Grouping>G16</Business_Partner_Grouping>
<Business_Partner_Type>G003</Business_Partner_Type>
<Title>002</Title>
<House_Number xsi:nil="true" />
<Street xsi:nil="true" />
<Street_2 xsi:nil="true" />
<Street_3 xsi:nil="true" />
<City>ABIDJAN</City>
<Country>CI</Country>
<City_Postal_Code xsi:nil="true" />
<Region xsi:nil="true" />
<PO_Box xsi:nil="true" />
<PO_Box_Postal_Code xsi:nil="true" />
<Language>FR</Language>
<Purpose>Z003 UNVs</Purpose>
<Telephone_Number />
<Mobile_Phone_Number>90075777</Mobile_Phone_Number>
<Fax_Number xsi:nil="true" />
<Email_Address>[email protected]</Email_Address>
<First_Name>Mickey</First_Name>
<Middle_Name xsi:nil="true" />
<Last_Name>Mouse</Last_Name>
<Gender>2</Gender>
<Index_Number>999999</Index_Number>
<Date_of_Birth>1969-11-29</Date_of_Birth>
<Nationality>CI</Nationality>
<DOB_Day>29</DOB_Day>
<DOB_Month>11</DOB_Month>
<DOB_Year>1969</DOB_Year>
<RelationBPGroupingBPType xsi:nil="true" />
<BPType_Z016>Z003</BPType_Z016>
<BPType_Z020 xsi:nil="true" />
<BPType_Z021 xsi:nil="true" />
<Sub_Area2>General and Banking</Sub_Area2>
<SR_Description>Business Partner Number:
Business Partner Type: UNVs
First Name: FirstName
Last Name: LastName</SR_Description>
<Sub_Area_Aux>79</Sub_Area_Aux>
<thereis_general>TRUE</thereis_general>
<thereis_banking>TRUE</thereis_banking>
<auxGeneric>GDB</auxGeneric>
<Business_Area_BP>P022</Business_Area_BP>
<Search_Term_1>FirstName</Search_Term_1>
<Search_Term_2>LastName</Search_Term_2>
<Responsible_Institution xsi:nil="true" />
<Add_Additional_Address xsi:nil="true" />
<Add_Additional_Communication xsi:nil="true" />
<BP_Role_Main xsi:nil="true" />
<BP_Role_Additional xsi:nil="true" />
<AddresType xsi:nil="true" />
<Specify xsi:nil="true" />
<BP_Category xsi:nil="true" />
<AddRemoveAddress xsi:nil="true" />
<AddRemoveCommunication xsi:nil="true" />
<BusinessAreaOfBP_Aux>MALI</BusinessAreaOfBP_Aux>
</General_Data>
<Primary_Bank_Account>
<Bank_Location_ID>0001</Bank_Location_ID>
<Bank_Country>ML</Bank_Country>
<Bank_Account_Number>XXXX999888777666555444-00</Bank_Account_Number>
<Bank_Account_Type>1</Bank_Account_Type>
<IBAN xsi:nil="true" />
<CurrencyPrimaryIBAN xsi:nil="true" />
<Account_Holder_Name xsi:nil="true" />
<CurrencyOPrimaryNationalBankAccount>XOF</CurrencyOPrimaryNationalBankAccount>
<Routing_Number_x002F__National_ID>BDMAMLBA</Routing_Number_x002F__National_ID>
<NonIbanAccountHolderName>BANKNAME</NonIbanAccountHolderName>
<NonIbanBankAccountNumber>TESTNIBAN</NonIbanBankAccountNumber>
<CurrencyOPrimaryBankAccountNonIBAN>XOF</CurrencyOPrimaryBankAccountNonIBAN>
<NonIbanPrimaryBankAccountType>1</NonIbanPrimaryBankAccountType>
<NonIbanPrimaryAccountNameOfBank>BANK OF AFRICA</NonIbanPrimaryAccountNameOfBank>
<NonIbanPrimaryAccountBankAddressHouseNumber>CDCI</NonIbanPrimaryAccountBankAddressHouseNumber>
<NonIbanPrimaryAccountBankAddressStreet>DALOA, COMMERCE</NonIbanPrimaryAccountBankAddressStreet>
<NonIbanPrimaryAccountBankAddressCity>DALOA</NonIbanPrimaryAccountBankAddressCity>
<NonIbanPrimaryAccountBankAddressRegion>DALOA</NonIbanPrimaryAccountBankAddressRegion>
<NonIbanPrimaryAccountBankAddressPostalCode>+225</NonIbanPrimaryAccountBankAddressPostalCode>
<Primary_Type_of_Account xsi:nil="true" />
<invisible1>National ID</invisible1>
<bDontHasBankAccount>false</bDontHasBankAccount>
<bBankAccountNotAvailable>false</bBankAccountNotAvailable>
<CashOrCheck xsi:nil="true" />
<CashAccountingClerk xsi:nil="true" />
<BankID_BIC_SWIFT>BIBS</BankID_BIC_SWIFT>
<CheckOptions xsi:nil="true" />
<SameOrDifferent_IBAN_Primary xsi:nil="true" />
<SameOrDifferent_National_Primary xsi:nil="true" />
<SameOrDifferent_NotIBAN_Primary>Yes</SameOrDifferent_NotIBAN_Primary>
<AccountTitle_IBAN_Primary xsi:nil="true" />
<AccountTitle_National_Primary xsi:nil="true" />
<AccountTitle_NotIBAN_Primary xsi:nil="true" />
<ExplainWhy_IBAN_Primary xsi:nil="true" />
<ExplainWhy_National_Primary xsi:nil="true" />
<ExplainWhy_NotIBAN_Primary xsi:nil="true" />
<Bank_Key xsi:nil="true" />
<Bank_Control_Key xsi:nil="true" />
<Special_Instructions_IBAN_Primary xsi:nil="true" />
<Special_Instructions_National_Primary xsi:nil="true" />
<Special_Instructions_NotIBAN_Primary xsi:nil="true" />
<RecordTypePrimary xsi:nil="true" />
<Payment_Method_UnderCashCheck xsi:nil="true" />
<ValidUntilPrimaryBank xsi:nil="true" />
</Primary_Bank_Account>
<Primary_Intermediary_Bank_Account>
<Intermediary_Bank_Location_ID xsi:nil="true" />
<Intermediary_Bank_Country xsi:nil="true" />
<Intermediary_Bank_Account_Number xsi:nil="true" />
<Intermediary_Bank_Account_Type xsi:nil="true" />
<Intermediary_IBAN xsi:nil="true" />
<CurrencyIntermediaryIBAN xsi:nil="true" />
<Intermediary_Account_Holder_Name xsi:nil="true" />
<CurrencyOIntermediaryNationalBankAccount xsi:nil="true" />
<Intermediary_Routing_Number_National_ID xsi:nil="true" />
<IntermediaryNonIbanAccountHolderName xsi:nil="true" />
<IntermediaryNonIbanBankAccountNumber xsi:nil="true" />
<CurrencyOIntermediaryBankAccountNonIBAN xsi:nil="true" />
<NonIbanIntermediaryBankAccountType xsi:nil="true" />
<NonIbanIntermediaryAccountNameOfBank xsi:nil="true" />
<NonIbanIntermediaryAccountBankAddressHouseNumber xsi:nil="true" />
<NonIbanIntermediaryAccountBankAddressStreet xsi:nil="true" />
<NonIbanIntermediaryAccountBankAddressCity xsi:nil="true" />
<NonIbanIntermediaryAccountBankAddressRegion xsi:nil="true" />
<NonIbanIntermediaryAccountBankAddressPostalCode xsi:nil="true" />
<IntermediaryBankAccountVisible xsi:nil="true" />
<Intermediary_Type_of_Account xsi:nil="true" />
<invisible2 xsi:nil="true" />
<Intermediary_BankID_BIC_SWIFT_code xsi:nil="true" />
<SameOrDifferent_IBAN_Intermediary xsi:nil="true" />
<SameOrDifferent_National_Intermediary xsi:nil="true" />
<SameOrDifferent_NotIBAN_Intermediary xsi:nil="true" />
<AccountTitle_IBAN_Intermediary xsi:nil="true" />
<AccountTitle_National_Intermediary xsi:nil="true" />
<AccountTitle_NotIBAN_Intermediary xsi:nil="true" />
<ExplainWhy_IBAN_Intermediary xsi:nil="true" />
<ExplainWhy_National_Intermediary xsi:nil="true" />
<ExplainWhy_NotIBAN_Intermediary xsi:nil="true" />
</Primary_Intermediary_Bank_Account>
<Additional_Bank_Account>
<Additional_Bank_Location_ID xsi:nil="true" />
<Additional_Bank_Country xsi:nil="true" />
<Additional_Bank_Account_Number xsi:nil="true" />
<Additional_Bank_Account_Type xsi:nil="true" />
<Additional_IBAN xsi:nil="true" />
<CurrencyAdditionalIBAN xsi:nil="true" />
<Additional_Account_Holder_Name xsi:nil="true" />
<CurrencyOAdditionalNationalBankAccount xsi:nil="true" />
<Additional_Routing_Number_x002F__National_ID xsi:nil="true" />
<AdditionalNonIbanAccountHolderName xsi:nil="true" />
<AdditionalNonIbanBankAccountNumber xsi:nil="true" />
<CurrencyOAdditionalBankAccountNonIBAN xsi:nil="true" />
<NonIbanAdditionalBankAccountType xsi:nil="true" />
<NonIbanAdditionalAccountNameOfBank xsi:nil="true" />
<NonIbanAdditionalAccountBankAddressHouseNumber xsi:nil="true" />
<NonIbanAdditionalAccountBankAddressStreet xsi:nil="true" />
<NonIbanAdditionalAccountBankAddressCity xsi:nil="true" />
<NonIbanAdditionalAccountBankAddressRegion xsi:nil="true" />
<NonIbanAdditionalAccountBankAddressPostalCode xsi:nil="true" />
<AdditionalBankAccountVisible xsi:nil="true" />
<Additional_Type_of_Account xsi:nil="true" />
<invisible3 xsi:nil="true" />
<Additional_BankID_BIC_SWIFT_code xsi:nil="true" />
<SameOrDifferent_IBAN_Additional xsi:nil="true" />
<SameOrDifferent_National_Additional xsi:nil="true" />
<SameOrDifferent_NotIBAN_Additional xsi:nil="true" />
<AccountTitle_IBAN_Additional xsi:nil="true" />
<AccountTitle_National_Additional xsi:nil="true" />
<AccountTitle_NotIBAN_Additional xsi:nil="true" />
<ExplainWhy_IBAN_Additional xsi:nil="true" />
<ExplainWhy_National_Additional xsi:nil="true" />
<ExplainWhy_NotIBAN_Additional xsi:nil="true" />
<Additional_Bank_Key xsi:nil="true" />
<Additional_Bank_Control_Key xsi:nil="true" />
<Special_Instructions_IBAN_Additional xsi:nil="true" />
<Special_Instructions_National_Additional xsi:nil="true" />
<Special_Instructions_NotIBAN_Additional xsi:nil="true" />
<RecordTypeAdditional xsi:nil="true" />
<ValidUntilAdditionalBank xsi:nil="true" />
</Additional_Bank_Account>
<Payment_Information>
<Block_for_payment>1</Block_for_payment>
<Payment_Method xsi:nil="true" />
<Accounting_Clerk xsi:nil="true" />
<PaymentMethodAdditional xsi:nil="true" />
<AccountingClerkAdditional xsi:nil="true" />
</Payment_Information>
<Additional_Field_for_Purchasing_view>
<Purchase_order_currency>XOF</Purchase_order_currency>
<BP_Role_for_Screen_Usage__x0028_Real_State_x0029_ xsi:nil="true" />
<Central_Block_for_Business_Partner>false</Central_Block_for_Business_Partner>
<Posting_block_for_company_code xsi:nil="true" />
<Deletion_Flag_for_Master_Record__x0028_Company_Code_Leve xsi:nil="true" />
<Purchasing_block_at_purchasing_organization_level xsi:nil="true" />
<Deletion_flag_for_vendor_at_purchasing_level xsi:nil="true" />
<BPRoleDateBegin xsi:nil="true" />
<BPRoleDateEnd xsi:nil="true" />
</Additional_Field_for_Purchasing_view>
<Requestor_Information>
<Requested_By>REQUESTOR</Requested_By>
<Org_Unit>MVCON</Org_Unit>
<Date>2014-05-19</Date>
<Reason xsi:nil="true" />
<On_Form xsi:nil="true" />
<Attached xsi:nil="true" />
<Located_In_x002F_At>TIMBUKTOU</Located_In_x002F_At>
<RequestorBusinessArea>P022</RequestorBusinessArea>
<RequestorBusinessAreaValue>MALI</RequestorBusinessAreaValue>
<Display_Review_Approval_Section xsi:nil="true" />
</Requestor_Information>
<Review_Information>
<Review_By xsi:nil="true" />
<Org_Unit xsi:nil="true" />
<Date xsi:nil="true" />
</Review_Information>
<Approval_Information>
<Approved_By xsi:nil="true" />
<Org_Unit xsi:nil="true" />
<Date xsi:nil="true" />
</Approval_Information>
<Reception_Information>
<Received_By xsi:nil="true" />
<Org_Unit xsi:nil="true" />
<Date xsi:nil="true" />
</Reception_Information>
<Entry_Information>
<Entered_By xsi:nil="true" />
<Org_Unit xsi:nil="true" />
<Date xsi:nil="true" />
</Entry_Information>
<Verification_Information>
<Verified_By xsi:nil="true" />
<Org_Unit xsi:nil="true" />
<Date xsi:nil="true" />
</Verification_Information>
<Order_Currency>
<Order_Currency_New xsi:nil="true" />
</Order_Currency>
<Change_BP_Group>
<BP_Group_Existing xsi:nil="true" />
<BP_Type_Existing xsi:nil="true" />
<BP_Role_Existing xsi:nil="true" />
<BP_Group_New xsi:nil="true" />
<BP_Type_New xsi:nil="true" />
<BP_Role_New xsi:nil="true" />
<BPTypeAuxVisible1 xsi:nil="true" />
<BPTypeAuxVisible2 xsi:nil="true" />
</Change_BP_Group>
<Expire_or_Add_Validity_Period_to_BP_Role>
<Additional_BP_Role_Entry xsi:nil="true" />
</Expire_or_Add_Validity_Period_to_BP_Role>
<Add_Alternative_Payees>
<Additional_Payee xsi:nil="true" />
</Add_Alternative_Payees>
<Establish_BP_Relationship>
<Additional_Relationship_EntryB xsi:nil="true" />
</Establish_BP_Relationship>
<Block_BP>
<PaymentBlock xsi:nil="true" />
<Reason_Payment_Block xsi:nil="true" />
<PostingBlock xsi:nil="true" />
<Reason_Posting_Block xsi:nil="true" />
<PurchasingBlock xsi:nil="true" />
<Reason_Purchasing_Block xsi:nil="true" />
<CentralBlock xsi:nil="true" />
<Reason_Central_Block xsi:nil="true" />
<FlagforArchiving xsi:nil="true" />
<Reason_Flag_Block xsi:nil="true" />
<TerminateBP xsi:nil="true" />
<Reason_Terminate_Block xsi:nil="true" />
</Block_BP>
<Options>
<Option1>true</Option1>
<Option2>false</Option2>
<Option3>true</Option3>
<Option4>false</Option4>
<Option5>false</Option5>
<Option6>false</Option6>
<Option7>false</Option7>
<Option8>false</Option8>
<Opt_Update_BP_legal_Name>false</Opt_Update_BP_legal_Name>
</Options>
<Sec_Update_BP_Legal_Name>
<NewLegalFirstName xsi:nil="true" />
<NewLegalMiddleName xsi:nil="true" />
<NewLegalLastName xsi:nil="true" />
</Sec_Update_BP_Legal_Name>
<line>
<IDType>
<IDType xsi:nil="true" />
<LegacyIDNumber xsi:nil="true" />
<Responsible_Institution_Legacy xsi:nil="true" />
<AddRemoveID_R xsi:nil="true" />
</IDType>
</line>
<Address>
<Section_Address>
<AddressTypeR xsi:nil="true" />
<StreetR xsi:nil="true" />
<StreetR_2 xsi:nil="true" />
<StreetR_3 xsi:nil="true" />
<House_NumberR xsi:nil="true" />
<City_Postal_CodeR xsi:nil="true" />
<CityR xsi:nil="true" />
<CountryR xsi:nil="true" />
<StateRegionProvinceR xsi:nil="true" />
<PO_BoxR xsi:nil="true" />
<PO_Box_PostalCodeR xsi:nil="true" />
<SpecifyR xsi:nil="true" />
<AddRemoveAddressR xsi:nil="true" />
</Section_Address>
<PO_BoxR2>
<SecPoBoxR2>
<PO_BoxR2 xsi:nil="true" />
<PO_Box_Postal_CodeR2 xsi:nil="true" />
</SecPoBoxR2>
</PO_BoxR2>
</Address>
<Communication>
<Communication_Section>
<Telephone_NumberR xsi:nil="true" />
<Mobile_Phone_NumberR xsi:nil="true" />
<Fax_NumberR xsi:nil="true" />
<Email_AddressR xsi:nil="true" />
<AddRemoveCommunicationR xsi:nil="true" />
</Communication_Section>
</Communication>
<Expire_or_Add_Validaty_to_BP_RoleR>
<Expire_or_Add_Validaty>
<BP_RoleR xsi:nil="true" />
<Expire_or_Add_Validity_PeriodR xsi:nil="true" />
<Valid_FromR xsi:nil="true" />
<Valid_ToR xsi:nil="true" />
</Expire_or_Add_Validaty>
</Expire_or_Add_Validaty_to_BP_RoleR>
<Add_Alternative_PayeesR>
<Alternative_Payees>
<Add_Update_Remove xsi:nil="true" />
<Permited_Payee_BP_NumberR xsi:nil="true" />
<Name_Alt_PayeeR xsi:nil="true" />
<Index_NumberR xsi:nil="true" />
<TitleR xsi:nil="true" />
<First_NameR xsi:nil="true" />
<Middle_NameR xsi:nil="true" />
<Last_NameR xsi:nil="true" />
</Alternative_Payees>
</Add_Alternative_PayeesR>
<Establish_BP_RelationshipR>
<Relationship>
<BP_Number_Main xsi:nil="true" />
<Relationship_CategoryR xsi:nil="true" />
<ValidFromR xsi:nil="true" />
<ValidToRelationshipR xsi:nil="true" />
<BPNumber_SecondaryR xsi:nil="true" />
<Index_Number_Secondary_Relationship xsi:nil="true" />
<Business_Area_Secondary xsi:nil="true" />
<Title_Secondary_BP xsi:nil="true" />
<First_Name_Secondary_BPR xsi:nil="true" />
<MiddleNameSecondaryBPR xsi:nil="true" />
<LastNameSecondaryBP xsi:nil="true" />
<Add_Update_DeleteR xsi:nil="true" />
</Relationship>
</Establish_BP_RelationshipR>
<PO_BoxR>
<SecPoBoxR>
<PO_BoxR xsi:nil="true" />
<PO_Box_Postal_CodeR xsi:nil="true" />
</SecPoBoxR>
</PO_BoxR>
</tns:OF_Forms>'
;WITH XMLNAMESPACES ('OF_Messages.Schemas.OF_Forms' AS tns)
SELECT m.n.value('(Bank_Account_Number)[1]','varchar(100)')
FROM @x.nodes('/tns:OF_Forms/Primary_Bank_Account')m(n)
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
XML Column from table extract to Pipe Delimited Text File
Hi,
I have an XML column with large data in a Table ( Source SQL server Database).
I was asked to extract XML column to .txt file using SSIS.
Is it possible to extract xml column with huge data to text file ?
when I tried, select XML column from Table in source , I noticed that Property of column is taken as [DT_NTEXT] . I Converted it to DT_TEXT as Ansi donot support DT_NTEXT.
Execution method was success but it failed due to trucation. so wondering is there a way to get XML column extracted to Pipe delimited text file?
Is it advisable to do this ? or IS It Valid to export XML in Pipe Delimited File ?
Please Kindly advice
thanks
kodiAre you looking at shredding data within XML nodes and then importing it to text file or are you looking at exporting XML value as is? Also is SSIS a necessity?
If not, You can simply use T-SQL for this along with bcp for this. just use a query like
EXEC xp_cmdshell 'bcp "SELECT CAST(XMLColumn AS varchar(max)) AS Column FROM table" queryout <full file path> -c -S <ServerName> -T -t |'
provided you use trusted connection (windows authentication)
see
http://visakhm.blogspot.in/2013/10/bcp-out-custom-format-data-to-flat-file.html
If you want to shred the data use Xpath functions in the query as below
http://visakhm.blogspot.in/2012/10/shred-data-as-well-as-metadata-from-xml.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to query from the xml table a single, specified element.
I'm quite new in Xml Db. Pleas, can anybody tell me how to query from the xml table below a single element (i.e. the element 'rapportoparentela = NIPOTE' related to the element 'codicefiscale = CRRVNC76R52G337R', or the element 'rapportoparentela = FIGLIO' related to the element 'codicefiscale = CRRRNT51L23G337Q')?
- <dati xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<codiceinterno />
<codicefiscaleassistito>CRRMNL81R31G337H</codicefiscaleassistito>
- <famigliare>
<codicefiscale>CRRVNC76R52G337R</codicefiscale>
<rapportoparentela>NIPOTE</rapportoparentela>
</famigliare>
- <famigliare>
<codicefiscale>CRRRNT51L23G337Q</codicefiscale>
<rapportoparentela>FIGLIO</rapportoparentela>
</famigliare>
- <famigliare>
<codicefiscale>CBRPRN15S65E080W</codicefiscale>
<rapportoparentela>I.S.</rapportoparentela>
</famigliare>
- <famigliare>
<codicefiscale>CRRMNL81R31G337H</codicefiscale>
<rapportoparentela>NIPOTE</rapportoparentela>
</famigliare>
- <famigliare>
<codicefiscale>BCCCML54C50I845G</codicefiscale>
<rapportoparentela>NUORA</rapportoparentela>
</famigliare>
</dati>
Using SELECT extractValue(value(t),'/rapportoparentela') into result FROM NF_XMLT X,
TABLE ( xmlsequence (extract(value(X),'/dati/famigliare/rapportoparentela'))) t
I get all the elements 'rapportoparentela' and I want to get only one specified.
Regards.
PieroPiero,
you can add the condition "CRRVNC76R52G337R" to your xpath-expression like:
SELECT extractValue(value(t),'/rapportoparentela')
FROM NF_XMLT x
,TABLE ( xmlsequence (extract(value(X),'/dati/famigliare[rapportoparentela="CRRVNC76R52G337R"]'))) tto select only those famigliare-elements that have a child-element rapportoparentela with value "CRRVNC76R52G337R".
When you stored your XML in an XMLType column in the table, i think the following queries are better:
SELECT extractValue(x.your_XMLType_column,'/dati/famigliare/rapportoparentela')
FROM NF_XMLT x
WHERE extractValue(x.your_XMLType_column,'/dati/famigliare/codicefiscale')
= 'CRRVNC76R52G337R'or
SELECT extractValue(x.your_XMLType_column,'/dati/famigliare/rapportoparentela')
FROM NF_XMLT x
WHERE existsNode(x.your_XMLType_column,'/dati/famigliare[codicefiscale="CRRVNC76R52G337R"]')
!= 0 -
Report Query using a Named Column Report Layout fails to produce PDF
I am testing FOP and the Shared Component Report Queries query with a Named Column Report Layout. The xsl file was built using Stylus Studio and worked fine with the saved XML data file in Stylus Studio.
500 Internal Server Error
500 Internal Server Error
Servlet error: An exception occurred.
The current application deployment descriptors do not allow for including it in this response.
Please consult the application log for details.
I assume this is a message from FOP. What do I do now?
tia,
SamSam,
I would suggest to take APEX out of the picture first and see if you can get this to work directly with your FOP solution, i.e. generate the XML data and take your XSL file and then post it directly to the FOP JSP (or whichever rendering engine you use). If this works, the problem might be somewhere in your APEX configuration. If it doesn't work, then the problem is likely in your XSL or XML structure. Here's how you can setup a static HTML page to post your XML and XSL to FOP:
http://marcsewtz.blogspot.com/2008/06/heres-another-posting-on-pdf-printing.html
Regards,
Marc -
Can't export XML column via postgres odbc driver
Hi,
I'm developing a process to export rows from a table in SQL server 2012 to a table in a Postgres database (9.3).
I'm using the postgres odbc driver in a linked server is SQL server.
I can read and insert across this linked server fine, however I have an XML column in the in the table and the process is failing with the following error.
INSERT into openquery(postgres_linked_server, 'SELECT column1, xml_column from mytable')
select top 1 column1, xml_column data_from mytable
Implicit conversion from data type xml to nvarchar is not allowed. Use the CONVERT function to run this query.
I've tried casting the source row to varchar/nvarchar, I've tried inserting it into a staging table in postgres with a character varying field. I'm reaching the conclusion that I need to extract the xml from sql server and insert it into postgres using an
intermediary. I'll try this with SSIS.
I was wondering if anyone had any experience of doing this with a linked server.
any comments appreciated.
Seansorry for the delay in replying, I've tried the second type of syntax and get
The OLE DB provider "MSDASQL" for linked server "postgres" supplied inconsistent metadata for a column. The column "xml_column" (compile-time ordinal 6) of object "postgres_linked_server"."database.schema"."mytable"
was reported to have a "DBCOLUMNFLAGS_ISLONG" of 128 at compile time and 0 at run time.
I'll look into it a little more, but I will try using an SSIS package as well to see if
I have any more luck with that.
thanks
Sean
Sean -
Hi,
Can anyone help me out please.
I have written one stored Procedure to create a views using Openrowset(openquery) but for tables which contains xml data types throwing error while executing the SP. Error
" Xml data type is not supported in distributed queries. Remote object 'OPENROWSET' has xml column(s)."
Please refer the Stored Procedure & error message below.
USE [Ice]
GO
/****** Object: StoredProcedure [dbo].[Pr_DBAccess] Script Date: 08/14/2014 16:08:20 ******/
SET
ANSI_NULLS ON
GO
SET
QUOTED_IDENTIFIER ON
GO
ALTER
PROCEDURE [dbo].[ Pr_DBAccess](@SERVERTYPE
NVARCHAR(50),@SERVERNAME
NVARCHAR(100),@DATABASENAME
NVARCHAR(100),@SCHEMANAME
NVARCHAR(100),@TABLENAME
NVARCHAR(100),@USERNAME
NVARCHAR(100),@PASSWORD
NVARCHAR(100))
AS
BEGIN
DECLARE @openquery
NVARCHAR(4000),
@ETL_CONFIG_IDN
NVARCHAR(100);
IF @SERVERTYPE='SQL'
BEGIN
SET @openquery=
'CREATE VIEW '+@TABLENAME+
' WITH ENCRYPTION AS SELECT * FROM OPENROWSET(''SQLNCLI'',''SERVER='+@SERVERNAME+';TRUSTED_CONNECTION=YES;'',''SELECT * FROM '+@DATABASENAME+'.'+@SCHEMANAME+'.'+@TABLENAME+''')'
SELECT @openquery
END
EXECUTE
sp_executesql @openquery
END
----While running the SP manually below error occuredHI ,
1. You cannot use a table or view that contains xml or clr type as 4-part name in your query
2. You need to cast the column to either nvarchar(max) or varbinary(max) or other appropriate type to use
3. If you have a table that has xml type for example then you need to create a view that contains all columns other than xml and query it instead. Or you can issue a pass-through query using OPEN QUERY with the appropriate columns only.
Here is a work around:
SELECT
Cast(a.XML_Data as XML) as XML_Data
FROM
OPENQUERY([LINKED SERVER NAME HERE],'
SELECT
Cast(XML_Data as Varchar) as XML_Data
FROM
[DATABASE NAME].[SCHEMA].[TABLE NAME]'
) a
Basically, the data is queried on the remote server, converts the XML data to a varchar, sends the data to the requesting server and then reconverts it back to XML.
You can take help from below link;
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/c6e0f4da-821f-4ba2-9b01-c141744076ef/xml-data-type-not-supported-in-distributed-queries?forum=transactsql
Thanks -
Little help with complex XML data as data provider for chart and adg
Hi all,
I've been trying to think through a problem and Im hoping for
a little help. Here's the scenario:
I have complex nested XML data that is wrapped by subsequent
groupings for efficiency, but I need to determine if each inner
item belongs in the data collection for view in a data grid and
charts.
I've posted an example at the bottom.
So the goal here is to first be able to select a single
inspector and then chart out their reports. I can get the data to
filter from the XMLListCollection using a filter on the first layer
(ie the name of the inspector) but then can't get a filter to go
deeper into the structure in order to determine if the individual
item should be contained inside the collection. In other words, I
want to filter by inspector, then time and then tag name in order
to be able to use this data as the basis for individual series
inside my advanced data grid and column chart.
I've made it work with creating a new collection and then
looping through each time there is a change to the original
collection and updating the new collection, but that just feels so
bloated and inefficient. The user is going to have some buttons to
allow them to change their view. I'm wondering if there is a
cleaner way to approach this? I even tried chaining filter
functions together, but that didn't work cause the collection is
reset whenever the .refresh() is called.
If anyone has experience in efficiently dealing with complex
XML for charting purposes and tabular display purposes, I would
greatly appreciate your assistance. I know I can get this to work
with a bunch of overhead, but I'm seeking something elegant.
Thank you.Hi,
Please use the code similar to below:
SELECT * FROM DO_NOT_LOAD INTO TABLE IT_DO_NOT_LOAD.
SORT IT_DO_NOT_LOAD by WBS_Key.
IF SOURCE_PACKAGE IS NOT INITIAL.
IT_SOURCE_PACKAGE[] = SOURCE_PACKAGE[].
LOOP AT IT_SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE.
V_SYTABIX = SY-TABIX.
READ TABLE IT_DO_NOT_LOAD into WA_DO_NOT_LOAD
WITH KEY WBS_Key = WA_SOURCE_PACKAGE-WBS_Key
BINARY SEARCH.
IF SY-SUBRC = 0.
IF ( WA_DO_NOT_LOAD-WBS_EXT = 'A' or WA_DO_NOT_LOAD-WBS_EXT = 'B' )
DELETE IT_SOURCE_PACKAGE INDEX V_SYTABIX.
ENDIF.
ENDIF.
ENDLOOP.
SOURCE_PACKAGE[] = IT_SOURCE_PACKAGE[].
ENDIF.
-Vikram -
Sql query generator from xml data
Hi,
I am looking for an open source tool in java which would generate the sql query with an xml configuration file as input. The xml configuration file schema would be defined by the tool and and would provide placeholders for giving the various information required to build the sql query.
Are there any available?
Please let me know.
Anshukhi All,
I tried below . but still no luck .
CREATE OR REPLACE FUNCTION get_audit_trail_log(cikey IN INTEGER) RETURN blob IS
CURSOR c_log(l_cikey INTEGER) IS
SELECT *
FROM PROD_SOAINFRA.audit_details atr
WHERE cikey = l_cikey
ORDER BY count_id;
bl BLOB;
BEGIN
dbms_lob.createtemporary (bl, TRUE);
FOR r_log IN c_log(cikey)
LOOP
dbms_lob.append (bl,r_log.log);
END LOOP;
RETURN(bl);
END;
=======================================
SELECT UTL_RAW.CAST_TO_VARCHAR2(UTL_COMPRESS.LZ_UNCOMPRESS(get_audit_trail_log(ci.cikey)))
FROM PROD_SOAINFRA.audit_details ci
WHERE cikey = 848063749
=======================================
Error:
=====================
ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 20958, maximum: 2000)
22835. 00000 - "Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: %s, maximum: %s)"
*Cause: An attempt was made to convert CLOB to CHAR or BLOB to RAW, where
the LOB size was bigger than the buffer limit for CHAR and RAW
types.
Note that widths are reported in characters if character length
semantics are in effect for the column, otherwise widths are
reported in bytes.
*Action: Do one of the following
1. Make the LOB smaller before performing the conversion,
for example, by using SUBSTR on CLOB
2. Use DBMS_LOB.SUBSTR to convert CLOB to CHAR or BLOB to RAW.
Maybe you are looking for
-
Prepare has not been completed succesfully
Hi Experts, I started an upgrade release 4.6C to ECC 6.0 on windows 2003 db version is SQL Server 2005, I am getting an error message at the begining of prepare phase, I've also updated sapup.exe version and source system kernel to 2364, how can i pr
-
IMovie HD 6, Imported Camcorder DV with Timecode, Displaying in iMovie
After importing a clip from my camcorder into iMovie HD 6.0.1 via FireWire, "Clip Info" does show the time and date the clip was recorded (the time according to the camcorder, not the time it was imported into iMovie). (Previous posts suggested that
-
Not able to modify list of approver on when Shopping Cart is on Hold
Hi All We are facing the following situation. We are creating a new shopping cart and then putting it on Hold. If we open the shopping cart again ( the SC being on Hold), we are not able to add or change the app rovers in approval flow. But if we or
-
Hi, I have the report generation toolkit and I want to save many waveform graph in a Word document. I've done the test and 10 pictures make my file 1Mb big. It is very possible that for this application I have to save much more graph. That would i
-
Setting monitor resolution in the login manager, before session launch
Hey guys, I want to have SLiM set the resolution to "auto" once it boots. At the moment, it seems like it boots directly into 800x600, and not into my native resolution, 1366x768. Sometimes I have an external monitor connected as well, and it's a goo