4

i need to call sqlcmd from stored procedure to export table to text file?

1

1 Answer 1

6

by the following way you can do this

exec master..xp_cmdshell 'echo pranay test application > d:\file.txt'

more about this : http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/how-to-copy-data-append-data-into-files-

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

3 Comments

i can't append to file like this
The > redirect overwrites, >> will append
Guess i'm making an easy mistake, but the file is looking like chinese characters instead of the simple "test" i am echoing-in.

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.