XML : adding an attribute to xml root in sql server

I am trying to create xml from sql server and I am almost done with my query. But, I have a problem that I couldnt figure it out. How can I add an attribute to root "ITEM", not "ITEMS"? My sql query is below...

  SELECT                CARD_TYPE              ,CODE              ,NAME              ,UNITSET_CODE              ,AUXIL_CODE              ,AUXIL_CODE2              ,AUXIL_CODE3              ,AUXIL_CODE4              ,AUXIL_CODE5              ,CYPHCODE         FROM P_ITEMS        WHERE HOSTGROUPID='7155d850-5882-43a0-b722-f6586bfffa61'          AND TRANCODE ='ITEMS'          AND PROCESSED ='NEW'          FOR XML PATH('ITEM'),ROOT('ITEMS')    

No comments:

Post a Comment