SSC-EWI-TS0067

Invalid parameters in OPENXML table-valued function.

Severity

Critical

Some parts of the output code are omitted for clarity reasons.

Description

This EWI is added when there are invalid parameters in the OPENXML, specifically when the XML path cannot be accessed.

To avoid this EWI, please send the explicit node path through the parameters.

Input Code:

IN -> SqlServer_01.sql
SELECT
    *
FROM
    OPENXML (@idoc, @path, 1) WITH (
        CustomerID VARCHAR(10),
        ContactName VARCHAR(20)
    );

Output Code:

OUT -> SqlServer_01.sql
SELECT
    *
FROM
    !!!RESOLVE EWI!!! /*** SSC-EWI-TS0067 - INVALID PARAMETERS IN OPENXML TABLE-VALUED FUNCTION ***/!!!
    OPENXML(@idoc, @path, 1);

Input code (Explicit parameter)

IN -> SqlServer_02.sql
SELECT
    *
FROM
    OPENXML (@idoc, '/ROOT/Customer', 1) WITH(
        CustomerID VARCHAR(10),
        ContactName VARCHAR(20)
    );

Output code (Explicit parameter)

OUT -> SqlServer_02.sql
SELECT
    Left(value:Customer['@CustomerID'], '10') AS 'CustomerID',
    Left(value:Customer['@ContactName'], '20') AS 'ContactName'
FROM
    OPENXML_UDF($idoc, ':ROOT:Customer');

Recommendations

Last updated