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 和 (c#, asp.net)。如何将选择语句结果写入 sql server 中的文本文件(具有 5 列和 30 多行的表)?我有一个包含数百个表和存储过程的数据库。
您可以通过 ISQL via 运行 selectxp_cmdshell并使用 -o 参数将结果输出到文件。此示例使用 -E 参数来避免对用户 ID 进行硬编码。
xp_cmdshell
declare @str varchar(255) select @str = 'isql -Q "select * from <tablename>" -E -o c:\text.txt' exec master.xp_cmdshell @str