Hi all,
im trying to write a stored procedure that will basically browse a folder and get me the first file that it sees. Is there any way that I can do this in TSQL or using CLR in C#? I was thinking something along the lines of using the dos dir command and triyng to pipe it into a variable, not sure how to go about doing this. Any suggestions?
dir /b ...gives me the bare file names, but it lists all the files in the folder, any way that i can just get the first file ( i dont really care what file).
|||create table #filelist
(
files varchar(500)
)
truncate table #filelist
insert #filelist
EXEC xp_cmdshell 'dir c:*.* /b'
select top 1 * from #filelist
This might help out:
http://stevekass.com/blog/wp-content/Folders/sql/TextDriver.htm
You can use TOP 1 to get just one file name.
Steve Kass
Drew University
http://www.stevekass.com
YoungEngineer@.discussions.microsoft.com wrote:
> Hi all,
>
> im trying to write a stored procedure that will basically browse a
> folder and get me the first file that it sees. Is there any way that I
> can do this in TSQL or using CLR in C#? I was thinking something along
> the lines of using the dos dir command and triyng to pipe it into a
> variable, not sure how to go about doing this. Any suggestions?
>
> dir /b ...gives me the bare file names, but it lists all the files in
> the folder, any way that i can just get the first file ( i dont really
> care what file).
>
>
>
>
No comments:
Post a Comment