在MSSQL的查询语句中,我怎么把查询结果存入到一个文件中去?

rwq_ 2001-10-09 11:38:43
比如:我要把select * from employee的查询结果放入文件:C;\中,另外,不能在SQL的查询分析器中指明“结果保存为文件....”,只能通过语句去实现!
...全文
93 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
karma 2001-10-09
  • 打赏
  • 举报
回复
use a system stored procedure:
1. xp_cmdshell "bcp <dbname>..employee out c:\file.fil -Usa -P<password> -c"

2.
declare @str varchar(255)
select @str = 'isql -Q"select * from employee" -E -oc:\file.fil'
exec master..xp_cmdshell @str


34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧