原来是win2000 server + sql2000,
现在升级到win2003 + sql2005,
有一个作业自动导出查询结果的,原来很正常,但是现在出现问题,不知如何解决
declare @sql as varchar(8000)
select @sql= 'BCP "select语句 保证正确" QUERYOUT \\168.192.2.6\data\data_daily.txt  -c -T'
EXEC master..xp_cmdshell @sql错误提示如下
SQLState = HY000, NativeError = 0
Error = [Microsoft][SQL Native Client]无法打开 BCP 主数据文件
NULL
\\168.192.2.6\data已经提前打通目录,如下,且运行正常
exec master..xp_cmdshell  'net use  \\109.120.2.30\ftng  seslft  /user:sesl-fs.seslcn.com\seslft'
请帮忙啊

解决方案 »

  1.   

    主要以前win2000+sql2000是正常的
      

  2.   

    --TRY
    exec master..xp_cmdshell 'dir \\168.192.2.6\data'
      

  3.   

    ---没有开启xp_cmdshell--开启xp_cmdshell
    --SQL Server blocked access to procedure 'xp_cmdshell'
    sp_configure 'show advanced options', 1
    go
    reconfigure
    go
    sp_configure 'xp_cmdshell', 1
    go
    reconfigure
    go--开启sp_OACreate
    --SQL Server blocked access to procedure 'sys.sp_OACreate'
    sp_configure 'show advanced options', 1;
    go
    reconfigure;
    go
    sp_configure 'ole automation procedures', 1;
    go
    reconfigure;
    go
    sp_configure 'Ad Hoc Distributed Queries',1;
    go
    reconfigure
    go
      

  4.   

    无法打开 BCP 主数据文件 
    ====================================
    看起来应该是 bcp 无法执行数据库查询。建议检查一下作业的所有者和 SQL SERVER AGENT 服务的服务账户。因为当作业所有者为 SYSADMIN 服务器角色成员时,非 T-SQL 作业步骤是在代理服务的服务账户的安全上下文中运行。