How to check network server is available

  • I am using xp_fileexist to check if the file exists on the network. It returns 0 either the file does not exist or the network is not available. I cannot determine which case causes the result.

    Does anyone know how to get it around?

  • Maybe you don't have permissions to access the network adress.

    you can also execute:

    master.dbo.cmdshell 'DIR \\NetPath\C$'

    to check that is available.

    Check the login account you use to run SQL Server. That account should be a Domain account with access to the adress you want.

  • If you insert the results from master.dbo.xp_cmdshell into a temp table you can use the table to check for certain results such as the file name, network path not found etc.

    create table #dirlist

    ( output varchar(255))

    insert #dirlist

    exec master.dbo.xp_cmdshell 'dir \\servername\dir\filename'

    drop table #dirlist

    Jeremy

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

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