How to use XQuery Exist() Function on a SSIS XML file

I have a Package Inventory table that has an XML Column named CurrentPackageXML. This XML column contains the SSIS Package XML. I need to use the XQuery Exist() function to determine if the
errorRowDisposition="IgnoreFailure" exists.
Below I have a basic SQL statement, but I have no idea how to write the Correct XQuery Expression. In my example below, I just tried to see if the DTS:Name Property existed, but that XQuery Expression is invalid also. It is not what I need in the end, but
I was just trying to get anything to work.
Below my SQL, I have included a snip-it of the SSIS package XML where I can find the errorRowDisposition. It is to the far right, so you may have to scroll to the right to see it. I bolded the text so it is easier to find.
Finally, once I have got a SQL statement that checks if errorRowDisposition exists = False, I need to check for every occurrence of  errorRowDisposition exists = False.
Would there be an easier way to do this by converting the XML to a varchar(max) then searching for all instances of  errorRowDisposition exists = False?
SELECT CurrentPackageXML.exist('/DTS:Executable/DTS:Property[DTS:Name]')
FROM [dbo].[PackageInventory]
<inputs>
<input id="43" name="OLE DB Destination Input" description="" hasSideEffects="true" dangling="false" errorOrTruncationOperation="Insert" errorRowDisposition="FailComponent" truncationRowDisposition="NotUsed">
<inputColumns>
<inputColumn id="113" name="" description="" lineageId="110" usageType="readOnly" errorOrTruncationOperation="" errorRowDisposition="NotUsed" truncationRowDisposition="NotUsed" externalMetadataColumnId="95" mappedColumnId="0" />
<inputColumn id="172" name="" description="" lineageId="167" usageType="readOnly" errorOrTruncationOperation="" errorRowDisposition="NotUsed" truncationRowDisposition="NotUsed" externalMetadataColumnId="94" mappedColumnId="0" />
</inputColumns>
<externalMetadataColumns isUsed="True">
<externalMetadataColumn id="50" name="DateCreated" description="" precision="0" scale="0" length="0" dataType="dbTimeStamp" codePage="0" mappedColumnId="0" />
<externalMetadataColumn id="51" name="ProcessedCount" description="" precision="0" scale="0" length="0" dataType="i4" codePage="0" mappedColumnId="0" />
<externalMetadataColumn id="52" name="ErrorCount" description="" precision="0" scale="0" length="0" dataType="i4" codePage="0" mappedColumnId="0" />
<externalMetadataColumn id="90" name="AcknowledgementID" description="" precision="0" scale="0" length="0" dataType="i4" codePage="0" mappedColumnId="0" />
<externalMetadataColumn id="91" name="Date" description="" precision="0" scale="0" length="0" dataType="dbTimeStamp" codePage="0" mappedColumnId="0" />
<externalMetadataColumn id="92" name="FileSeqNumber" description="" precision="0" scale="0" length="0" dataType="i4" codePage="0" mappedColumnId="0" />
<externalMetadataColumn id="93" name="FileType" description="" precision="0" scale="0" length="50" dataType="str" codePage="65001" mappedColumnId="0" />
<externalMetadataColumn id="94" name="FileName" description="" precision="0" scale="0" length="50" dataType="str" codePage="65001" mappedColumnId="0" />
<externalMetadataColumn id="95" name="DateReceived" description="" precision="0" scale="0" length="0" dataType="dbTimeStamp" codePage="0" mappedColumnId="0" />
</externalMetadataColumns>
</input>
</inputs>
Ryan P. Casey • <a href="http://www.R-P-C-Group.com">www.R-P-C-Group.com</a>

Try this and let know what errors you get.  Note, this is a rough draft of one of a series of queries that I have started writing to document SSIS using SQL XQuery.  I read a file in my version (the one I tested) and get the results.
-- Get the flat file destinations and their mappings
with xmlnamespaces ('www.microsoft.com/SqlServer/Dts' as DTS
), compflow as (
SELECT
task.xml.value('@DTS:ObjectName', 'varchar(200)') as TaskName
, task.xml.value('@DTS:ExecutableType', 'varchar(200)') as TaskType
, task.xml.value('@DTS:refId', 'varchar(1000)') as TaskRefId
--, task.xml.query ('.') as Node
, component.xml.value ('@name', 'varchar(200)') as ComponentName
, component.xml.value ('@refId', 'varchar(1000)') as ComponentRefId
, component.xml.value ('@componentClassID', 'varchar(1000)') AS componentClassID
--, component.xml.value ('count(inputs/input)', 'int') AS NumberOfInputs
--, component.xml.value ('count(outputs/output)', 'int') AS NumberOfOutputs
--, component.xml.value ('count(outputs/output[@isErrorOut="true"])', 'int') AS NumberOfErrorOutputs
, component.xml.query('.') as ComponentNode
FROM [dbo].[PackageInventory] pk
cross apply pk.CurrentPackageXML.nodes('//DTS:Executable[@DTS:ExecutableType="Microsoft.Pipeline"]') as task (xml)
OUTER APPLY task.xml.nodes('DTS:ObjectData/pipeline/components/component') as component (xml)
WHERE [PackageInventory_ID] = 13
, inputNode as (
SELECT c.*
, input.xml.value ('@name', 'varchar(200)') as InputName
, input.xml.value ('@refId', 'varchar(1000)') as InputRefId
, input.xml.value ('@hasSideEffects', 'varchar(1000)') as InputHasSideEffects
, input.xml.value ('count(inputColumns/inputColumn)', 'int') AS NumberOfInputColumns
, input.xml.value ('count(externalMetadataColumns/externalMetadataColumn)', 'int') AS NumberOfExternalMetadataColumns
, input.xml.value ('@errorOrTruncationOperation', 'varchar(1000)') as InputerrorOrTruncationOperation
, input.xml.value ('@errorRowDisposition', 'varchar(1000)') as InputerrorRowDisposition
, col.xml.value ('@errorOrTruncationOperation', 'varchar(1000)') as InputColumnErrorOrTruncationOperation
, col.xml.value ('@errorRowDisposition', 'varchar(1000)') as InputColumnErrorRowDisposition
from compFlow c
OUTER APPLY c.ComponentNode.nodes ('component/inputs/input') as input (xml)
OUTER APPLY input.xml.nodes ('inputColumns/inputColumn') as col (xml)
, inputAnal as (
select
TaskName
,TaskType
,TaskRefId
,ComponentName
,ComponentRefId
,componentClassID
,InputName
,InputRefId
,InputHasSideEffects
, Null as IsError
,NumberOfInputColumns
,NumberOfExternalMetadataColumns
,InputerrorOrTruncationOperation
,InputerrorRowDisposition
,InputColumnErrorOrTruncationOperation
,InputColumnErrorRowDisposition
, count(*) as NumRec
from inputNode
group by TaskName
,TaskType
,TaskRefId
,ComponentName
,ComponentRefId
,componentClassID
,InputName
,InputRefId
,InputHasSideEffects
,NumberOfInputColumns
,NumberOfExternalMetadataColumns
,InputerrorOrTruncationOperation
,InputerrorRowDisposition
,InputColumnErrorOrTruncationOperation
,InputColumnErrorRowDisposition
, xoutputNode as (
SELECT
TaskName
,TaskType
,TaskRefId
,ComponentName
,ComponentRefId
,componentClassID
, xout.xml.value ('@name', 'varchar(200)') as OutputName
, xout.xml.value ('@refId', 'varchar(1000)') as OutputRefId
, xout.xml.value ('@hasSideEffects', 'varchar(1000)') as OutputHasSideEffects
, xout.xml.value ('@isErrorOut', 'varchar(1000)') as OutputIsError
, xout.xml.value ('count(outputColumns/outputColumn)', 'int') AS NumberOfOutputColumns
, xout.xml.value ('count(externalMetadataColumns/externalMetadataColumn)', 'int') AS NumberOfExternalMetadataColumns
, xout.xml.value ('@errorOrTruncationOperation', 'varchar(1000)') as OutputerrorOrTruncationOperation
, xout.xml.value ('@errorRowDisposition', 'varchar(1000)') as OutputerrorRowDisposition
, col.xml.value ('@errorOrTruncationOperation', 'varchar(1000)') as OutputColumnErrorOrTruncationOperation
, col.xml.value ('@errorRowDisposition', 'varchar(1000)') as OutputColumnErrorRowDisposition
from compFlow c
OUTER APPLY c.ComponentNode.nodes ('component/outputs/output') as xout (xml)
OUTER APPLY xout.xml.nodes ('outputColumns/outputColumn') as col (xml)
, outputAnal as(
select
TaskName
,TaskType
,TaskRefId
,ComponentName
,ComponentRefId
,componentClassID
,OutputName
,OutputRefId
,OutputHasSideEffects
,OutputIsError
,NumberOfOutputColumns
,NumberOfExternalMetadataColumns
,OutputerrorOrTruncationOperation
,OutputerrorRowDisposition
,OutputColumnErrorOrTruncationOperation
,OutputColumnErrorRowDisposition
, count (*) as NumberOfRows
from xoutputNode
group by TaskName
,TaskType
,TaskRefId
,ComponentName
,ComponentRefId
,componentClassID
,OutputName
,OutputRefId
,OutputHasSideEffects
,OutputIsError
,NumberOfOutputColumns
,NumberOfExternalMetadataColumns
,OutputerrorOrTruncationOperation
,OutputerrorRowDisposition
,OutputColumnErrorOrTruncationOperation
,OutputColumnErrorRowDisposition
select 'Input' as RowType, i.* from inputAnal i
union all
select 'Output' as RowType, o.* from outputAnal o
Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

Similar Messages

  • How to use the CMS functionality in Sun Portal Server 7.2

    Hi All,
    How to use the CMS functionality using the ccd.war(Portlet) which is available in the library as i could add it to my channel but not able to show the functionality as it is showing the error msg "You are currently not logged in. Please login." should I create userid and there respective roles inorder to use the CMS functionality.
    Has any one used this as I could this in glass fish server.
    Any Input is appreciated.
    Thanks & regards
    Srikanth

    Have a look at the "*Roles*" section of the portal server 7.2 content management system guide
    http://docs.sun.com/source/820-4275/index.html . You can also look at [project mirage|https://mirage.dev.java.net] for some screencasts
    Alternatively,
    1. ccd.war has 3 portlets in it:
    (a) custom content definition portlet
    (b) custom content portlet
    (c) workflow portlet
    2. Inorder to work with these portlets, user needs to be in anyone of the below roles:
    (a)Consumer (b) Editor (c) Approver (d) Administrator (e) Submitter (f) Contributor (g) Publisher
    3. By default ccd.war gets deployed using a default roles file (/var/opt/SUNWportal/tmp/ccd.roles.properties)
    Note: In windows, you may not find this file
    4. Access the portlets as a user in any of the role mentioned in the ccd.roles.properties
    (OR)
    you can use a new roles file which has mapping to your custom roles. For this , undeploy existing ccd.war and deploy again with a new roles.properties file
    Hope this helps!

  • Does anyone know how to use the bcc functionality for apple mail while accessing it on the cloud from my PC?

    I am currently away from my MAC and want to send an email through apple mail with the bcc functionality.  I am using the cloud to get to my mail, however, I can't figure out how to use the BCC functionality, please help.  Thanks!

    Open your mail,
    lower left corner click on settings,
    go to composing and check BCC, save and your done

  • How to Use the language function for assignment and validation

    Hi All,
    If anyone can explain me in details with example ,how to use the language function for assignments and validations?
    Thanks
    Arnab

    Hi Arnab,
    The expression is checked only for the current MDM session.
    If u login with the ABC language it will always show the ABC language no matter how many times u execute it.
    Try connecting to the DM with the XYZ language.
    It should go to the if part rather than else.
    Hope it helps.
    Thanks,
    Minaz

  • How to use the divide() function in bpel

    Hi All,
    How to use the divide() function in bpel.
    pls can u give the one sample example

    2 div 4
    Eg;
    <assign name="Assign_1">
    <copy>
    <from expression="2 div 4"/>
    <to variable="outputVariable" part="payload"
    query="/client:testProcessResponse/client:result"/>
    </copy>
    </assign>
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to use xsl document() function with LiveCycle XSLT processor

    Hello,
    I would like to use LiveCycle XSLT processor to merge xml documents by using the xsl document() function.
    However, I have not, yet, found  clear reference information on the specifics of how to accomplish in LC. For instance if you have
    a transformation that does merging using a standalone xml editor (such as Oxygen), than what is required to accomplish the same
    using the LiveCycle XSLT service.  How do you specify the URI of the XML document that is specified as an input in the xsl document() function. Your insight is appreciated.   Regards

    Hello Steve,
    I checked the reference that you cited (XSLT Transformation).   The reference omits discussing how to use xlst document() function within a stylesheet.  I think that probably means that feature of xslt technology is not directly available through LiveCycle.  When I find a workaround, I'll post an update...for the user community that might encounter the same issue.  Thank you for your response and insight.  Regards, jb1809

  • How to use query-database() function in transformation?

    Hi All,
    How to use query-database() function in transformation?
    It is giving four fields but if i write select query in sqlquery field it is saying select node is not found....
    plz help me out
    Regards
    Pavankumar
    Edited by: [email protected] on Jul 29, 2009 2:49 AM

    Hi,
    To answer your query:-
    http://abhishek-soablog.blogspot.com/2008/08/orclquery-database.html
    Cheers,
    Abhi...

  • How to use the set functions effectively in webi ,please let me know with detail

    how to use the set functions effectively in webi ,please let me know with detail

    Hi,
    we use use set functions on heirarchies with aggregate functions mostly .
    If you include member_set, Min returns the minimum value of the aggregated data for all members in the member set.
    Member_set can include multiple sets separated by semicolons (;).
    The list of member sets must be enclosed in {}.
    If the member set expression does not specify a precise member or node, the hierarchy referenced must be present in the table, then the member set expression references the current member in the hierarchy in the table. If the hierarchy is not in the table, the function returns the message #MULTIVALUE.
    Eg .
    1)     Ancestor
    =Sum([YTD] ; {Ancestor([Test Hierarchy];2)})
    2)     IsLeaf
    =[Test Hierarchy].IsLeaf
    You can use this function when you want to show your Measure only at lower level .
    3)     .Depth
    =[Test Hierarchy].Depth
    This is also function used with hierarchy to find Level of Members .
    Follow this link for PDF reference .
    Page 147
    https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&ved=0CDIQFjAB&url=https%3A%2F%2Fhelp.sap.com%2Fbusinessobject%2Fproduct_guides%2Fboexir4%2Fen%2Fxi4sp5_ffc_en.pdf&ei=nBAUU-iUM4WWrAeMuoCoDg&usg=AFQjCNHakXsEjd_yUk2y3lVdibf3PXpEOA&bvm=bv.61965928,d.bmk
    search on SCN this question was discussed before also one those links .
    http://scn.sap.com/thread/3183380
    Hope this will help you .

  • How to use Round off function in TAX Formula

    Dear All,
             I have to do Round off in the Tax Formula. Hence I was suggested by the SAP Forum Team to use Round off function in the Tax Formulae.
             But sir I don't know how to use Round off function in the Tax Formulae.
            For Eg. BaseAmt = Total
                        TaxAmt = BaseAmt * Rate
               Now within this Eg. How will i use the Round off function and where i will use it.
               Please guide me with example.
      Regards
    Hitesh Parsawala

    Hi Hitesh,
    you can do like this
    Cess_ST_TaxAmt=Round(Cess_ST_BaseAmt*Cess_ST_Rate,0)
    where you can introduce rounding function by choosing from dropdown available in Operation and by click on Insert.
    It will post following in formulla window
    Round (Number, Decimals as Number)
    where in parameter you have to give 1.Number-which is to be round and 2.Decimals as Number-as per your requirement like by 2 decimal or 0 decimal
    If required give me call,
    BR
    Samir Gandhi

  • How to use Spell-check functionality for textbox (like Orkut, gtalk)

    How to use Spell-check functionality for tex Hello Friends,
    I am working on a JSP application. I wanted to add Spell check for text box like we have here, when we post a message. It automatically shows red line under the word, when ever spelling is wrong. Please tell me how I can do this. If possible, the code too.
    Thanks.

    I believe the spell checking you see here, or on any other site, is the spell checking built into Firefox. At least that's what I see. Are you using Firefox?

  • How to use a C function as a native method

    Could anybody tell me how to use a C function as a Java native method.
    Thanks

    Read all about it.
    You'd probably have to write a little wrapper (using JNI) that passes
    parameters and return values around between your C function and
    the JVM.
    kind regards,
    Jos

  • How to use a partner function?

    1. I would like to link a project (or WBS) to the Invoice Approver (for the workflow)
    2. I would like to link a project to a Customer or several Customers
    3. I would like to link a project to a Vendor or number of Vendors
    Not clear how to use a partner function for that reason and where this will be visible.

    Getting following error message for the Customer:
    Customer for function Y2 may not have account group Z010
    Message no. VP303
    Why and where such restrictions are applied?

  • How to use case when function to calculate time ?

    Dear All,
    May i know how to use case when function to calculate the time ?
    for the example , if the First_EP_scan_time is 12.30,  then must minus 30 min.  
    CASE WHEN FIRSTSCAN.EP_SHIFT <> 'R1' AND FIRSTSCAN.EP_SHIFT <> 'R2'
    THEN ROUND(CAST((DATEDIFF(MINUTE,CAST(STUFF(STUFF((CASE WHEN SHIFTCAL.EP_SHIFT = 'N1'
    THEN CONVERT(VARCHAR(8),DATEADD(DAY,+1,LEFT(FIRSTSCAN.EP_SCAN_DATE ,8)),112) + ' ' + REPLACE(CONVERT(VARCHAR(8),DATEADD(HOUR,+0,SHIFTDESC.EP_SHIFT_TIMETO + ':00'),108),':','')
    ELSE LEFT(FIRSTSCAN.EP_SCAN_DATE ,8) + ' ' + REPLACE(CONVERT(VARCHAR(8),DATEADD(HOUR,+0,SHIFTDESC.EP_SHIFT_TIMETO + ':00'),108),':','') END),12,0,':'),15,0,':') AS DATETIME),CAST(STUFF(STUFF(LASTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME)) / 60.0 - 0.25) AS FLOAT),2)
    ELSE ROUND(CAST((DATEDIFF(MINUTE,CAST(STUFF(STUFF(FIRSTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME),CAST(STUFF(STUFF(LASTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME)) / 60.0) AS FLOAT),2) END AS OTWORK_HOUR

    Do not use computations in a declarative language.  This is SQL and not COBOL.
    Use a table of time slots set to one more decimal second of precision than your data. You can now use temporal math to add it to a DATE to TIME(1) get a full DATETIME2(0). Here is the basic skeleton. 
    CREATE TABLE Timeslots
    (slot_start_time TIME(1) NOT NULL PRIMARY KEY,
     slot_end_time TIME(1) NOT NULL,
     CHECK (start_time < end_time));
    INSERT INTO Timeslots  --15 min intervals 
    VALUES ('00:00:00.0', '00:14:59.9'),
    ('00:15:00.0', '00:29:59.9'),
    ('00:30:00.0', '00:44:59.9'),
    ('00:45:00.0', '01:00:59.9'), 
    ('23:45:00.0', '23:59:59.9'); 
    Here is the basic query for rounding down to a time slot. 
    SELECT CAST (@in_timestamp AS DATE), T.start_time
      FROM Timeslots AS T
     WHERE CAST (@in_timestamp AS TIME)
           BETWEEN T.slot_start_time 
               AND T.slot_end_time;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to use 'several screen function' used to be in os x 10.6

    hi ! ^^
    how r u ? good !
    how to use 'several screen function' used to be in os x 10.6 ??
    it was possible to change whole screen with 'command + arrow keys' (option + arrow keys maybe ??)
    but, in os x 10.7, it seems it is not possible. and instread of it 'mission controls' that is not uesful ..
    no windows drive direct access. no several screen function. crash when control panel ask me administration right.
    os x 10.5 or 10.4 was much easy to control.  
    plz fix and add good functions of 10.6 , remove good functions is not called 'upgrade'.

    You can still do it with CONTROL + Arrow keys, the same as 10.6
    Regards,
    Captfred

  • How to find suitable( existing) function group for a Function Module ?

    How to find suitable( existing) function group for a Function Module to be created?
    This is FM for converting amounts to text.

    Hi,
            If you are not sure into which Function group your FM should go in then its advised to create a Function group of your own. Its not advised to create a function module in any other function group unless its owned by you since your FM can get deleted by others or it can get changed.
    Create your own Function group. But if you want to create in an existing FG then best way is to find out the Function Group by searching for suitable existing Function module then see their function group
    Regards,
    Sesh

Maybe you are looking for

  • Renewal: distorted employee photos

    Hi, I have to finish a task for my former colleague who left our company . We display photos of our employees. The photos don't look like the origin photos - they are distorted. Have a look at this (distorted photo): This is the origin photo: Maybe w

  • Ios7: adding albums to playlists

    When making a playlist in Music in former iOS's if you went to your albums button there used to be an "add all" button to add an album and now it's not there so if you want to add two 15 song albums to a playlist that's 30 careful clicks (to get corr

  • Problem #1: Elements Organizer 10 (and before that 9) crash frequently

    I'm a long time PSe user (since at least v4).  Currently using PSe 10. I have a decent sized library of images (over 13,000) pretty much all just my digital snapshots. I moved everything over to a new Win7 PC.  Plenty powerful, plenty of storage. Why

  • Turn spell check on?

    Finding the auto spell check annoying, I turned it off. I now can't find any way to turn it back on!Help!

  • Create a RowCounter as cannot use rownumber as select has orderby

    Say I have a select statement Select employee_no,salary,dept order by salary which would give the result Employee_no Salary dept 2045 1000 G 3067 2000 A 1089 3000 P i want a counter in the next column to read 1,2,3 i.e Employee_no Salary dept CNTR 20