SQL - How to write table into a file within a sql script

tommym121
tommym121 used Ask the Experts™
on
I would like to write each record of a table into a line within a file.  This should be all done within the sql script that I generate the table.
I would like to be able to select the seperator character for the columns within the file.

Any idea?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Chief Database Architect
Commented:
hi

Execute master..xp_cmdshell 'bcp YOURdb..YOURtable out c:\temp\Afile.txt -c'

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial