可以在存储过程中,把执行的SQL写入txt文件吗?txt文件则是以当天日期为文件名
谢谢

解决方案 »

  1.   

    utl_file.fopen( p_dir, p_filename, 'w', p_max_linesize);
    utl_file.put(  );
      

  2.   

    EXEC master..xp_cmdshell  ‘echo’+ @你想要写入日志的变量 + '>>d:\4.txt'
     
    例如:将8写入d:\盘4.txt文件中
    EXEC master..xp_cmdshell  'echo 8 >>d:\4.txt', no_output
      

  3.   

     哈哈,我今天就用这个来实现了。。 
    我用的是C# 调用SQL master 数据库的系统存储过程 跟楼上的差不多。。
    EXEC   master..xp_cmdshell     ‘echo’+   @你想要写入日志的变量   +   '> > d:\4.txt ' 
      

  4.   

    EXEC   master..xp_cmdshell   'bcp   pubs.dbo.sales   out   c:\temp1.txt   -c   -q    -S"."   -U"sa"   -P"123"'