Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outputting a file from SQL on different lines instead of a single line

Status
Not open for further replies.

july07

Programmer
Aug 26, 2009
33
US
Im trying to get an output file from a sql database on a .txt file, but all the out puts are on one line, how do i get them on different lines. Below is my code:

Code:
SELECT name, access, description, number syntax FROM testingresults 
WHERE LIKE 'testing%' AND access='read-write'"

This what im getting:
{testing1 read-write {This testing went well.} {} Integer32} {testing2 read-write {This testing went well.} {} Integer32}{testing3 read-write {This testing went well.} {} Integer32}{testing4 read-write {This testing went well.} {} Integer32}

I want this output instead:
{testing1 read-write {This testing went well.} {} Integer32}
{testing2 read-write {This testing went well.} {} Integer32}
{testing3 read-write {This testing went well.} {} Integer32}
{testing4 read-write {This testing went well.} {} Integer32}

Any help will be appreciated, Thanks!
 
Why not use XML?

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
SELECT name, access, description, number syntax FROM testingresults
WHERE LIKE 'testing%' AND access='read-write'" FOR XML AUTO
 
At Markros,

Im not familiar with XML.

So please can you explain your post better.

By the way, im using Tcl programming to get the output.

Thanks!
 
Thank you Markros. i have gone through the link but im still kind of confused on how to implement it.

Do i have to download a program to do this, or could i do this using tcl programming.

Thanks!
 
No, That is pure T-SQL code, no need to download or install anything.

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Since the output is for a text file, would it be possible to use CHAR(13) in the results set?
Code:
declare @results nvarchar(max) 
set @results = '' 
select  @results =  @results +  name + ',' + access + ',' + description + ',' + number syntax + CHAR(13) FROM testingresults
WHERE LIKE 'testing%' AND access='read-write'
Print @results
(assuming all fields to be CHAR(n))

soi la, soi carré
 
Yes, you can do this as well assuming only small number of records.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top