Reputation: 33
Is there a way to make a stored procedure (along with the other things it's supposed to do) create a text file on a local hard drive?? I've heard it is possible, but when I've searched for it on the inet I've only found how to export "result sets" into text files.. but that's not what I need, I need something simple enough that helps me know the stored procedure is being executed when called from a C# webapp. So it would be best to have an instruction inside the SP that creates a file on a specified route with some text like "hello world" or "passed by here"; something like that. I was thinking that maybe if I could execute a windows command line from the SP, I could create the file...
I apologize if this was asked before, I'm feeling pretty sure it didn't, from the search and research I did before asking.
Thank you guys for your kind advices!
Upvotes: 1
Views: 3425
Reputation: 1569
You can use xp_cmdshell. So something like this:
exec xp_cmdshell 'echo hello world > c:\status\file.txt'
Upvotes: 1