November 20, 2003 at 2:34 pm
From within a SQL Server Stored Procedure, is it possible to read through a cursor writing each record to a unique text file whose name is dynamically generated based on a field within the cursor record retrieved?
Please Help!
Thank You
November 21, 2003 at 2:12 pm
Yes you have to use the OA ole creation method to open filesystem objects
see BOL
quote:
How to create an OLE Automation object (Transact-SQL)To create an OLE Automation object
Call sp_OACreate to create the object.
Use the object.
Call sp_OAGetProperty to get a property value.
Call sp_OASetProperty to set a property to a new value.
Call sp_OAMethod to call a method.
Call sp_OAGetErrorInfo to get the most recent error information.
Call sp_OADestroy to destroy the object.
November 21, 2003 at 3:01 pm
Two other ways...
xp_cmdshell using echo >> (the double greater than sign appends). For instance:
xp_cmdshell 'echo Write to a text file >> c:\temp\test.txt'
Second, is using Jet and a linked server connection. However, there is some prep work (see sp_addlinkedserver in BOL).
K. Brian Kelley, GSEC
http://www.truthsolutions.com/
Author: Start to Finish Guide to SQL Server Performance Monitoring
K. Brian Kelley
@kbriankelley
November 26, 2003 at 9:02 am
Just did some poking around and I am getting an ole automation error message on the example I did.
OLE Automation Error Information
HRESULT: 0x8002801d
Source: ODSOLE Extended Procedure
Description: Library not registered.
What library? Running SQL2000, sp3a
Thanks,
Chris
November 26, 2003 at 10:35 am
quote:
Just did some poking around and I am getting an ole automation error message on the example I did.OLE Automation Error Information
HRESULT: 0x8002801d
Source: ODSOLE Extended Procedure
Description: Library not registered.
What library? Running SQL2000, sp3a
Thanks,
Chris
Can you post what you did?
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply