1

is there a simple way to just output each record in a select statement to write to its own file?

for example, if you have the tsql query in sql server 2005,

select top 10 items, names + ':' + address from book 

and you ended up with 10 text files with the individual name and addresses in each file.

is there a way to do this without writing an extensive spWriteStringToFile procedure? I'm hoping there is some kind of output setting or something in the select statement.

thanks in advance

3 Answers 3

1

SQL returns the result set first, there's no opportunity in there for writing records to specific files until afterwards.

Being SQL Server 2005, it's possible you could use a SQLCLR (.NET 2.0 code) function in a SQL statement without having to make a separate application.

Sign up to request clarification or add additional context in comments.

Comments

1

In SSMS, you can do a results to file, but that wouldnt split each record out into its own file. I pretty sure you cannot do this out of the box, so it sounds like you will be rolling your own solution.

Comments

1

You'd do this in some client, be it Java, VBA or SSIS typically.

1 Comment

i was hoping to avoid using some kind of client. it looks like i will have to crank this out in vba.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.