最好用tj_dns的方法。
declare @cmdline varchar(2000)
SELECT @cmdline = 'bcp "select a.text from syscomments a,sysobjects b where b.type=''P'' and b.status>0 and a.id=b.id order by a.id" queryout c:\t.txt -c  -Usa -Pruirui'
exec master..xp_cmdshell @cmdline以上如果是加密过程,是乱码。

解决方案 »

  1.   

    最好用tj_dns的方法。
    declare @cmdline varchar(2000)
    SELECT @cmdline = 'bcp "select a.text from syscomments a,sysobjects b where b.type=''P'' and b.status>0 and a.id=b.id order by a.id" queryout c:\t.txt -c  -Usa -Ppasswd'
    exec master..xp_cmdshell @cmdline以上如果是加密过程,是乱码。
      

  2.   

    : teaism() ( 
    你说的办法为什么生成的t.txt里面什么记录都没有??
      

  3.   

    选择所需要生成文本文件的存储过程,点右键选择所有任务——〉生成sql脚本
      

  4.   

    但是那样生成的脚本好象把前面的那一段
    if exist(select name from ))
    和后面的
    grant all on aa to public
    给去掉了啊
    有什么办法能够保留的吗?
      

  5.   

    SELECT @cmdline = 'bcp "select a.text from syscomments a,sysobjects b where b.type=''P'' and b.status>0 and a.id=b.id order by a.id" queryout c:\t.txt -c  -Usa -Ppasswd'可以解释一下这条命令吗?
      

  6.   

    选择所需要生成文本文件的存储过程,点右键选择所有任务——〉生成sql脚本注意:
        请选中"选项"选项卡中的"表脚本"选项中4项全选,再生成脚本,他就会保存存储过程的所有信息
      

  7.   

    CSFish(海里唯一的鱼) ( ) 
    按照你的方法试过了
    的确可行
    拿分吧