tsql - What is :XML ON in T-SQL query to export data into XML using SQLCMD? -
tsql - What is :XML ON in T-SQL query to export data into XML using SQLCMD? -
on blog post exporting info xml tsql using bcp or sqlcmd came across line of code:
:xml on select * dbo02.exceltest xml auto, elements, root('doc') i tried using in sql query , triggering via sqlcmd in batch file, did homecoming right xml file. without :xml on returns unusual values described on webpage.
strangely enough, ssms (2008) shows wrong syntax when parsing or executing query.
what :xml on , how utilize it? , why doesn't ssms recognize line of code?
it explained in msdn page (search ":xml"): sqlcmd utility
that pages states:
xml output result of xml clause output, unformatted, in continuous stream.
when expect xml output, utilize next command: :xml on.
note sqlcmd returns error messages in usual format. notice error messages output in xml text stream in xml format. using :xml on, sqlcmd not display informational messages.
to set xml mode off, utilize next command: :xml off.
the go command should not appear before xml off command issued because xml off command switches sqlcmd row-oriented output.
xml (streamed) info , rowset info cannot mixed. if xml on command has not been issued before transact-sql statement outputs xml streams executed, output garbled. if xml on command has been issued, cannot execute transact-sql statements output regular row sets.
note :xml command not back upwards set statistics xml statement.
in ssms, if enable "sqlcmd mode" (in query menu), next error trying utilize :xml command:
scripting warning. command xml not supported. string not processed. this due particular command not beingness needed within context of query editor.
xml tsql bcp sqlcmd sql-server-2008
Comments
Post a Comment