Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Get list of files from the directory using sp_OAmethod

$
0
0

Hi,

  how to get the list of files name from the directory using sp_OAmethod or sp_OAgetproperty(scripting.filesystemobject) in sql server 2008. I tried with below query but I'm unable to get the fileid from this method. Anyone help me to fix this issue.

declare

@ObjFileSystem int,

@ObjFolID

int,

@ObjFilID

int,

@ObjItemID

int

EXEC

dbo.sp_OACreate'Scripting.FileSystemObject', @ObjFileSystem OUT

EXEC

dbo.sp_OAMethod@ObjFileSystem,'GetFolder', @ObjFolID OUT,'C:\temp'

EXEC

dbo.sp_OAMethod@ObjFolID,'Files', @ObjFilIDOUT

EXEC

dbo.sp_OAMethod@ObjFilID,'Items', @ObjItemIDOUT

select

@ObjItemID


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>