Assume that I have created a employees table which has 10 records. How to create a stored procedure to export all the records into the log file.

Showing Answers 1 - 3 of 3 Answers

sujatha

  • Jun 25th, 2007
 

In the SQL prompt write down set spool
the file name is either log file or any one.
Press Enter.
After that write select command for which records you want to store in that file.
Next open the file
Finally set spool off.

  Was this answer useful?  Yes

Dheeraj Chakravarthy

  • Oct 10th, 2007
 

Create Procedure TestExport
as
Begin

xp_cmdshell 'bcp "SELECT * from YourDatabase.dbo.YourTable" QueryOut d:Temptest.xls -S alexissqlsrv01 -U dpi -P Value*() -c -T'

End

All the Best.

- Dheeraj.

  Was this answer useful?  Yes

Create Procedure TestExport
as
Begin

xp_cmdshell 'bcp "SELECT * from YourDatabase.dbo.YourTable" QueryOut d:Temptest.xls -S alexissqlsrv01 -U dpi -P Value*() -c -T'

End

All the Best.

- Dheeraj.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions