working with files with T-Sql

  • Hi,

    I need to know if a file on the network exist with t-sql. Is that possible?

    Example:

    IF (file on the network exist) BEGIN ... END

    Thanks,

    Eric

  • declare@Path varchar(128) ,

    @FileName varchar(128)

    select@Path = \\ServerName\ShareName\' ,

    @FileName = 'file.txt'

    declare @fe int

    declare@File varchar(1000)

    select @File = @Path + @FileName

    exec master..xp_fileexist @File, @fe out

    if @fe = 1

    print 'exists'

    else

    print 'not exists'

     


    * Noel

  • thanks! exactly what I needed!

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

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