本机上运行能够完成,但是在其他电脑上却提示错误,特来请教..使用xp_cmdshell的SQL语句:EXEC master..xp_cmdshell 'osql -S 192.168.1.10 -U sa -P sa -d tmpPOS -i E:\DB\1.sql'本机上可以运行,放其他电脑除E:\DB\1.sql这里的SQL存放路径发生变化外其他都不变.执行返回错误:Cannot open input file - E:\DB\1.sql
No such file or directory
但是如果单独在其他电脑上运行osql -S 192.168.1.10 -U sa -P sa -d tmpPOS -i E:\DB\1.sql这一句是成功的,放在SQL中就产生了错误.是不是我遗漏了哪里?求教...谢谢!

解决方案 »

  1.   

    其它电脑的外围配置管理器--〉把 xp_cmdshell 选项打开
      

  2.   

    1、路径对没?
    2、xp_cmdshell 开没。
      

  3.   

    回1楼:麻烦说下SQL 2008 R2的这个在哪里开....- -回2楼:1.路径是对的.
    2.你是说我运行的客户端?
      

  4.   

    EXEC sp_configure 'xp_cmdshell', 1
      

  5.   

    EXEC sp_configure 'show advanced options', 1
    GO
    RECONFIGURE
    GO
    EXEC sp_configure 'xp_cmdshell', 1
    GO
      

  6.   

    把那个xp_cmdshell 打开 一个服务选项
      

  7.   

    回4楼:EXEC sys.sp_configure 'show advanced options',1
    GO
    RECONFIGURE
    GO
    EXEC sys.sp_configure 'xp_cmdshell',1
    GO
    RECONFIGURE
    GO
    EXEC master..xp_cmdshell 'osql -S 192.168.1.10 -U sa -P sa -d tmpPOS -i E:\DB\1.sql'
    GO
    EXEC sys.sp_configure 'show advanced options',1
    GO
    RECONFIGURE
    GO
    EXEC sys.sp_configure 'xp_cmdshell',0
    GO
    完整的...我都写了的
      

  8.   

    回8楼:
    执行下面的语句:EXEC xp_cmdshell 'dir *.exe'
    执行成功....
      

  9.   

    回10楼:这个文件夹是在我本地的,我只是想把这个SQL文件执行到服务器.
      

  10.   

    算了,我直接用cmd调用osql弄了.谢谢大家!