transact sp_OAMethod's parameters for Scripting.FileSystemObject object

juarrero used Ask the Experts™

I am working with OLE Automation to deal with windows folders and files from inside SQL Server.

I can create an object of type Scripting.FileSystemObject. But when using the stored procedure sp_OAMethod to perform some work on it, I barely know a few parameters as 'FolderExists' or 'CreateFolder'.

I have found some pages like with provides a description for a set of specific methods of the object for VBScript and JScript, equivalent to use "sp_OAMethod + parameter" in transact.

I would need to find out the same detailed information for transact sp_OAMethod for Scripting.FileSystemObject. Thas is, information of the many parameters for this method and object.

Thanks in advance,

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database Developer and Administrator
You can do it the following way:
declare @result int;
declare @objectFs int;
declare @folder_exists bit;
declare @folder_name nvarchar(1000) = 'C:\Temp';

exec @result = sp_OACreate N'Scripting.FileSystemObject', @objectFs output;
if @result <> 0 return;
exec @result = sp_OAMethod @objectFs, 'FolderExists', @folder_exists output, @folder_name;
if @result <> 0 return;
if @folder_exists = 0
	exec @result = sp_OAMethod @objectFs, 'CreateFolder', @result output, @folder_name; 

exec sp_OADestroy @objectFs;

Open in new window

Máté FarkasDatabase Developer and Administrator

User did not react on a perfect and tested answer.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial