Home Forums SQL Server 2005 T-SQL (SS2K5) I need to import xml to temp table but the tag is dynamic. How can I do it? RE: I need to import xml to temp table but the tag is dynamic. How can I do it?

  • Hi, thanks for answer but I would like know if you can resolve my problem without import the xml at sql table because I have many process before this condition and I am working with varchar(max) variable .

    Example of code that I have before this condition

    ;WITH XMLNAMESPACES(DEFAULT 'http://www.portalfiscal.inf.br/nfe')

    SELECT

    @chvnfe = Substring(X.emit.query('data(../@Id)').value('.', 'VARCHAR(44)'),4,47),

    @cnpjcli = X.emit.query('../dest/CNPJ').value('.', 'CHAR(14)'),

    @cnpjemp = X.emit.query('CNPJ').value('.', 'CHAR(14)'),

    @emissao = X.emit.query('../ide/dhEmi').value('.', 'CHAR(19)'),

    @doc = X.emit.query('../ide/nNF').value('.', 'CHAR(06)'),

    @serpdv = X.emit.query('../ide/serie').value('.', 'CHAR(09)'),

    @VlrTot = X.emit.query('../total/ICMSTot/vProd').value('.','NUMERIC(16,2)')

    FROM @xml.nodes('nfeProc/NFe/infNFe/emit') AS X(emit)

    Is it possible?

    Thanks