Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 XML

Author  Topic 

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-02-10 : 07:45:30
HI...
I want to EXPORT SqlTable in to XML Format.

ANy Idea On This..

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-10 : 07:46:46
SELECT * FROM Table1 FOR XML AUTO

And use bcp to export?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

heavymind
Posting Yak Master

115 Posts

Posted - 2009-02-10 : 08:11:02
read working with xml article
http://db-staff.com/index.php/microsoft-sql-server/74-working-with-xml

Thanks, Vadym
MCITP DBA 2005/2008
Chief DBA at http://www.db-staff.com
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-02-10 : 08:24:28
Thanks Peso ......

For Ur Needful Help.....

well thats query works fine with me,,,
i get that table in XML format,,,
cna i please tell me the way in which i can xport that xml file in particular destination using BCP...with store procedure,,,,

Thanks For your help....

M new in Sql Server So help me out in this.

Thnaks.....
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-02-10 : 09:26:33
i Use that query for export the XML file,,,,

bcp "select * from ashish.dbo.test13 FOR XML RAW" queryout d:\myfile.xml -creative8\sqlexpress -sa -1 -c -r -t


But it gives me the error....



Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'queryout'.

Any Suggestions.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-10 : 09:27:06
http://msdn.microsoft.com/en-us/library/ms191184.aspx
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-02-10 : 10:12:59
means i dont know can u knw wats the problem wid dis?
i dunn have any idea about this so guide me?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-10 : 10:26:48
something like:-

bcp "select * from ashish.dbo.test13 FOR XML RAW" queryout d:\myfile.xml -S creative8\sqlexpress -U sa -1 -c -r <row terminator here> -t <field terminator here>
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-02-12 : 00:11:58
ohkk Thanks Vishak Sir,,
I also found a solution,,,,,
mean it works for me...
so,,,it is like....


EXEC master..xp_cmdshell 'bcp "select * from Ashish.dbo.webmba2 for XML AUTO" queryout D:\myfile2.xml -Screative8\sqlexpress -Uusername -Ppassword -c -r -t'

Thanks For Reply...

Go to Top of Page
   

- Advertisement -