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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I write and read from text file in stored procedure

Status
Not open for further replies.

go2bharat

Programmer
Apr 10, 2005
1
US
I an new to SQL server and was wondering if it is possible for me to run queries in a SP and write the result set to a file (lets say ASCII file). Later, can I read data from this ascii file in the SP and then lets say use it to insert values in some tables? Is it possible to do this?
 
Put the information you want into a global temporary table and then bcp it out to a file via xp_cmdshell.

xp_cmdshell "bcp <dbname>..<tablename> out c:\yourfile.txt -Usa -P<password> -c
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top