Reputation: 399
What is the SQL 2008 code to open a file, append some new lines, and save the file. Is there a way to do this all inside a stored procedure? Also, is there a way to automatically retrieve the script to do this from a "Tasks"->"Generate Scripts" menu options, or at least get close.
Upvotes: 2
Views: 2293
Reputation: 3318
You can do it with plain T-SQL...
to make it work, click on those links in the text as well...
http://www.simple-talk.com/code/WorkingWithFiles/uftReadFileAsTable.txt
http://www.simple-talk.com/code/WorkingWithFiles/spWriteStringTofile.txt
Or you might write a function in c#...
http://blog.adampresley.com/2009/writing-csharp-functions-for-sql-server-and-clr-integration/
Upvotes: 3