Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 SQL Server 2008 中执行存储过程并将数据存储在文本文件中。如何执行此操作以及如何使用 SQL Server 2008 中的数据自动生成文本文件?
其中一种方法是使用 BCP(批量复制程序)来执行此操作。您需要启用 xp_cmdshell 才能使其正常工作。
您也可以使用 SSIS 导入/导出向导来实现这一点。
EXEC master..xp_cmdshell 'BCP "exec dbname.schemaname.procname" queryout "C:\outputfile.txt" -T -c -t,'
看看这些: