SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Trivial example of XML output from SQLCMD
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

PhilipLewis
Starting Member

18 Posts

Posted - 10/14/2013 :  15:30:14  Show Profile  Reply with Quote
I am trying to get SQLCMD to execute a stored procedure which outputs XML to a named file

create procedure [dbo].[aaa]
as
begin
select top 1 * from dbo.MyTable for xml auto, elements
end


This works when executed from SSMS. Output to text returns a heading line and underline, followed by the appropriate XML output.


I tried this command from the CLI

C:> sqlcmd
:XML ON
-S "MYNODE" -E -Q "set nocount on; execute [MyDB].[dbo].[aaa]" -o C:\temp\aaa.xml
:EXIT


It returns the heading line and underline, followed by a very long string of what appear to be concatenated HEX numbers
I tried this on various major versions with the same results.


Despite the fact that I have made an attempt to read the manual, obviously I am still doing something totally wrong.
The ":XML ON" command has no apparent effect.

A clue or two would be appreciated.

James K
Flowing Fount of Yak Knowledge

3334 Posts

Posted - 10/14/2013 :  16:36:15  Show Profile  Reply with Quote
Try it like this:
sqlcmd -S "MYNODE"
>:XML ON
>set nocount on; execute [MyDB].[dbo].[aaa]" -o C:\temp\aaa.xml
>GO
>EXIT
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000