1

I have an XML file like this

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Header/>
    <env:Body>
        <ns0:getDateIdentificareResponse xmlns:ns0="/asdf/asdf/types/">
            <ns1:result xmlns:ns0="/asdf/asdf/" xmlns:ns1="/asdf/asdf/types/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns0:CustomerSDO">
                <ns0:Cif>1</ns0:Cif>
                <ns0:Cui>2</ns0:Cui>
                <ns0:CategorieClient>mm</ns0:CategorieClient>
                <ns0:NrInregistrare>xxxx</ns0:NrInregistrare>
                <ns0:CodCaen>dsaads</ns0:CodCaen>
                <ns0:Telefon xsi:nil="true"/>
                <ns0:AdresaSediu>
                    <ns0:Cif>2</ns0:Cif>
                    <ns0:Tara>2</ns0:Tara>
                    <ns0:Judet>3</ns0:Judet>
                    <ns0:Localitate>4</ns0:Localitate>
                    <ns0:CodPostal xsi:nil="true"/>
                    <ns0:Sector xsi:nil="true"/>
                    <ns0:Strada>5</ns0:Strada>
                    <ns0:Numar>6</ns0:Numar>
                    <ns0:Bloc xsi:nil="true"/>
                    <ns0:Scara xsi:nil="true"/>
                    <ns0:Etaj xsi:nil="true"/>
                    <ns0:Apartament xsi:nil="true"/>
                    <ns0:BulkAddress>sddsa</ns0:BulkAddress>
                </ns0:AdresaSediu>
                <ns0:AdresaCorespondenta>
                    <ns0:Cif>2</ns0:Cif>
                    <ns0:Tara>2</ns0:Tara>
                    <ns0:Judet>3</ns0:Judet>
                    <ns0:Localitate>4</ns0:Localitate>
                    <ns0:CodPostal xsi:nil="true"/>
                    <ns0:Sector xsi:nil="true"/>
                    <ns0:Strada>5</ns0:Strada>
                    <ns0:Numar>6</ns0:Numar>
                    <ns0:Bloc xsi:nil="true"/>
                    <ns0:Scara xsi:nil="true"/>
                    <ns0:Etaj xsi:nil="true"/>
                    <ns0:Apartament xsi:nil="true"/>
                    <ns0:BulkAddress>sddsa</ns0:BulkAddress>
                </ns0:AdresaCorespondenta>
                <ns0:BeneficiariReali>
                    <ns0:CifClient>Valuue</ns0:CifClient>
                    <ns0:CifBeneficiar>Valuue</ns0:CifBeneficiar>                   
                </ns0:BeneficiariReali>
                <ns0:BeneficiariReali>
                    <ns0:CifClient>Valuue</ns0:CifClient>
                    <ns0:CifBeneficiar>Valuue</ns0:CifBeneficiar>

                </ns0:BeneficiariReali>
                <ns0:Conturi>
                    <ns0:CifClient>Valuue</ns0:CifClient>
                    <ns0:CifBeneficiar>Valuue</ns0:CifBeneficiar>
                </ns0:Conturi>
                <ns0:Imputerniciti>
                    <ns0:CifClient>Valuue</ns0:CifClient>
                    <ns0:CifBeneficiar>Valuue</ns0:CifBeneficiar>
                </ns0:Imputerniciti>
            </ns1:result>
        </ns0:getDateIdentificareResponse>
    </env:Body>
</env:Envelope>

And I can't find a way to import data in SQL. I know it should be fairly easy acording to

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

https://dba.stackexchange.com/questions/117005/import-xml-files-into-sql-server-2012

But I'm missing something. Running the second question solution won't get my anything. And for the first question I have no idea what to write as paramater for XMLNAMESPACES.

Can anyone help me? Thank you

1 Answer 1

1

Try to use *

SELECT t.c.value('(*:Cif/text())[1]', 'INT')
FROM @x.nodes('*:Envelope/*:Body/*:getDateIdentificareResponse/*:result') t(c)
Sign up to request clarification or add additional context in comments.

2 Comments

Thank it, it's what I need to get it started!
Also you can check this video about xml issues: youtube.com/watch?v=fu6o5Cw0XzU

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.