Matthewabq


I am pulling my hair out about this. Whenever I execute the following script with sqlcmd (SQL Server 2005) the output is always on one line even when there are thousands of records returned:

:XML on
SELECT *
FROM SomeTable
FOR XML AUTO, ELEMENTS

How can I get the output to be formatted with each element on a separate line I tried other specifiers such as EXPLICIT, RAW, etc. but the output always ends up on a single line.





Re: output of sqlcmd "select * from 'tableName' for XML... " all on one line

Sinan Ussakli - MSFT


Hi,

You need to use: FOR XML EXPLICIT instead of FOR XML. But have a look at the following document first:

http://msdn2.microsoft.com/en-us/library/aa226532(SQL.80).aspx

Thanks,

Sinan