Jump to content
Sign in to follow this  
Juin

Varchar incompatible with XML

Recommended Posts

Juin

É possivel fazer algo do género disto para escrever para xml

SELECT text as [@text], input as [@input], input_id as [@in_id] from Evento WHERE campos IN
			(SELECT campos as [@camps] FROM Evento FOR XML PATH('campo'), TYPE, ROOT('campos') ) FOR XML PATH('tipo'), TYPE, ROOT('tipos')

o resultado que procuro com isso é

<tipos>
<tipo>
  <campos>
   <campo>
   </campo>
  </campos>
</tipo>
</tipos>

Share this post


Link to post
Share on other sites
Caça

Para o formato que queres, não, o máximo que consegues com isso é

SELECT TEXT AS [@TEXT], INPUT AS [@INPUT], input_id AS [@in_id] 
FROM Evento 
FOR XML PATH('tipo'), TYPE, ROOT('tipos')

<tipos>
  <tipo TEXT="..." INPUT="..." in_id="..." />
  <tipo TEXT="..." INPUT="..." in_id="..." />
  <tipo TEXT="..." INPUT="..." in_id="..." />
  <tipo TEXT="..." INPUT="..." in_id="..." />
  <tipo TEXT="..." INPUT="..." in_id="..." />
</tipos>

O mais parecido para o que queres, será talvez assim

SELECT TEXT AS [@TEXT], INPUT AS [@INPUT], input_id AS [@in_id], campos 
FROM Evento 
FOR XML PATH('tipo'), TYPE, ROOT('tipos')


Pedro Martins

Não respondo a duvidas por PM

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.