bcp 可以实现数据的导入导出。
EXEC master..xp_cmdshell 'bcp test.dbo.P_Aspect in c:\temp1.txt -c -q -S"servername" -U"sa" -P""'
//导入 EXEC master..xp_cmdshell 'bcp test.dbo.P_Aspect out c:\temp1.txt -c -q -S"servername" -U"sa" -P""'
//导出

解决方案 »

  1.   

    先定义一个DTS《表1 ——〉文本》
    然后将你的查询结果存入表1
    执行DTS
      

  2.   

    here is an detailed example:DECLARE @FileName varchar(50),
            @bcpCommand varchar(2000)SET @FileName = REPLACE('c:\authors_'+CONVERT(char(8),GETDATE(),1)+'.txt','/','-')SET @bcpCommand = 'bcp "SELECT * FROM pubs..authors ORDER BY au_lname" queryout "'
    SET @bcpCommand = @bcpCommand + @FileName + '" -U garth -P pw -c'EXEC master..xp_cmdshell @bcpCommand