Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    212

    Unanswered: Check if a file exists using sql

    Is there is a piece for code ot sample code that can let me check if a file exists? Has any one done this before?

    Thanks

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Re: Check if a file exists using sql

    Try this idea.

    create table #tmp(result varchar(100))
    go
    insert #tmp
    exec master..xp_cmdshell 'dir filename.txt'
    select * from #tmp where result like '%filename.txt%'

  3. #3
    Join Date
    Sep 2003
    Posts
    212

    Re: Check if a file exists using sql

    Originally posted by snail
    Try this idea.

    create table #tmp(result varchar(100))
    go
    insert #tmp
    exec master..xp_cmdshell 'dir filename.txt'
    select * from #tmp where result like '%filename.txt%'
    I found another method to do this. I used the xp_fileexist command and it works well. The idea above works as well

    Thanks for the input.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •