SQL Server 2008 R2 Writing To Text File
- by zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
I used to write to text files from SQL Server using the code listed below:
DECLARE @FS INT --File System Object
DECLARE @OLEResult INT --Result message/code
DECLARE @FileID INT --Pointer to file
--Create file system object (OLE Object)
EXECUTE @OLEResult = sp_OACreate 'Scripting.FileSystemObject', @FS OUT
IF @OLEResult <> 0 PRINT 'Scripting.FileSystemObject.Failed'
-----OPEN FILE-----
EXECUTE @OLEResult = sp_OAMethod @FS, 'OpenTextFile', @FileID OUT, @FileName, 8, 1
IF @OLEResult <> 0 PRINT 'OpenTextFile.Failed'
It appears this is no longer supported in sql server 2008 r2. How should I export to text files in sql server 2008 r2?
Link claiming this is no longer supported:
http://social.msdn.microsoft.com/Forums/en/transactsql/thread/f8512bec-915c-44a2-ba9d-e679f98ba313