export table data to text file

  • HI

    CT_ID CT_name CT_parentID

    100Rudraksha0

    101Power malas0

    102Gems & jewellery0

    103Yantra 0

    104Puja items0

    105Rosaries 0

    106Vastu 0

    107Books 0

    108Music 0

    109Gifts 0

    110Agarbathi 0

    111chains 0

    NULLNULL NULL

    i converted this data to xml format

    through query

    select * from TB_Category for xml auto

    result i s as below

    <TB_Category CT_ID="100" CT_Catname="Rudraksha" CT_Parentid="0"/><TB_Category CT_ID="101" CT_Catname="Power malas" CT_Parentid="0"/><TB_Category CT_ID="102" CT_Catname="Gems & jewellery" CT_Parentid="0"/><TB_Category CT_ID="103" CT_Catname="Yantra" CT_Parentid="0"/><TB_Category CT_ID="104" CT_Catname="Puja items" CT_Parentid="0"/><TB_Category CT_ID="105" CT_Catname="Rosaries" CT_Parentid="0"/><TB_Category CT_ID="106" CT_Catname="Vastu" CT_Parentid="0"/><TB_Category CT_ID="107" CT_Catname="Books" CT_Parentid="0"/><TB_Category CT_ID="108" CT_Catname="Music" CT_Parentid="0"/><TB_Category CT_ID="109" CT_Catname="Gifts" CT_Parentid="0"/><TB_Category CT_ID="110" CT_Catname="Agarbathi" CT_Parentid="0"/><TB_Category CT_ID="111" CT_Catname="chains" CT_Parentid="0"/>

    BUT i want to export this xml file to local folder in my machine , what is the query for export& import xmlfile at serverside

    i want to store xmlfile in folder how to store

  • Hi,

    You can try SQLCMD utility:

    - create xml.sql file

    :XML ON

    select top 10 * from Address for xml auto

    - start cmd.exe, run this command:

    sqlcmd -S SQL2008 -E -d TestDB -i C:\xml.sql -o C:\xml_output.txt

  • Is this a one time thing or something you'll be doing more than once?

    If more than once, I suggest using SSIS to create a package that you can kick off as needed.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply