Reading the images name kept in a folder through stored procedure

  • Hi All

    Can anyone please tell me how can i get the name of the images kept in a specified folder on the system through stored procedure in sql server 2005 and 2000.I want to read the name of the images through stored procedure and insert them into a table.

    It is very very urgent.Please help me

    Thanks in advance

    Nothing Is Impossible

  • This script will help you...

    CREATE TABLE [dbo].[MyDir] (

    [Dir] varchar(255)

    )

    GO

    TRUNCATE TABLE MyDir

    DECLARE @cmd varchar(4000)

    SELECT @cmd = 'Dir c:\*.*'

    INSERT INTO MyDir(dir)

    EXEC master..xp_cmdshell @cmd

    SELECT CONVERT(datetime,SUBSTRING(dir,1,20)) AS [Create_Time]

    , CONVERT(int,LTRIM(RTRIM(REPLACE(SUBSTRING(dir,21,19),',','')))) AS [File_Size]

    , SUBSTRING(dir,40,(LEN(dir)-39)) AS [File_Name]

    , 'FILE'

    FROM MyDir

    WHERE (SUBSTRING(dir,1,1) ' '

    AND SUBSTRING(dir,25,5) CHAR(60)+'Dir'+CHAR(62))

    drop table MyDir

    Got it from SQLteam and modified it according to the requirement.

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply