transact sp_OAMethod's parameters for Scripting.FileSystemObject object


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,

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Máté FarkasDatabase Developer and AdministratorCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Máté FarkasDatabase Developer and AdministratorCommented:
User did not react on a perfect and tested answer.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.