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.
| Author |
Topic |
|
corningfann
Starting Member
2 Posts |
Posted - 2006-05-17 : 17:17:07
|
| How to add the line breaks after each node when I use "for xml explicit"? I would appreciate it for any suggestion. |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-05-18 : 01:23:27
|
I don't think you can. You'd need to run it through some sort of pretty-printer.Is there a reason why you need to do this - only humans need the line breaks, don't they? Kristen |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-05-18 : 01:24:43
|
| On second thoughts this may be a question related to the fact that for xml explicit generates output as a STREAM rather than a RESULTSET (assuming I've got my terminology correct!) so anything expecting a conventional resultset, like Query Analyser, is going to make the output look like a mess.Kristen |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-18 : 02:29:49
|
| Where do you want to show data?Sounds that you should do this in front end applicationMadhivananFailing to plan is Planning to fail |
 |
|
|
corningfann
Starting Member
2 Posts |
Posted - 2006-05-18 : 11:04:39
|
quote: Originally posted by corningfann How to add the line breaks after each node when I use "for xml explicit"? I would appreciate it for any suggestion.
Guys,Thank you very much! I used "dbcc traceon(257)" and got the link breaks after each node. I have a question to save this file?I have the sql script that return xml via "FOR XML EXPLICIT" clause. I can specify output to file in Query Analyzer. Is it possible to save output file as file extension .ctl? |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-05-18 : 12:37:31
|
| I use BCP for ad-hoc XML output. It gives me warning messages about line length, but otherwise works just fine."C:\Program Files\Microsoft SQL Server\80\Tools\Binn\bcp.exe" "EXEC MyDatabase.dbo.MySProc" queryout X:\MyPath\MyFile.XML -SMyServer -UMyUserID -PMyPassword -c -r -tIf you want to surround the file with <ROOT> tag you can append to that:& echo ^<root^> >junk1.$$$ & echo ^</root^> >junk2.$$$ & copy /B junk1.$$$+X:\MyPath\MyFile.XML+junk2.$$$ X:\MyPath\MyFile2.XML & del X:\MyPath\MyFile.XMLKristen |
 |
|
|
|
|
|