将Sql表导出到本地计算机上的文本文件 [英] Export Sql Table To text file On Local Machine

查看:138
本文介绍了将Sql表导出到本地计算机上的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All

我想将Sql表导出到文本文件

我这样做是通过

exec master..xp_cmdshell''bcp 选择* FRom Db..Table as tqueryoutC:\ A.Axt.txt-c -T -SServer_Name''

它没问题但它将结果导出到服务器

我想将此结果导出到myPc而不是服务器

任何帮助请。

解决方案

您可以创建一个powershell脚本作为您的要求并执行它。它会将您的sqlserver数据存储到本地或任何共享位置。如果你还没有,你就可以对powershell有一个基本的想法。然后去以下网站:

http:// billfellows.blogspot.com/2011/03/powershell-export-query-to-csv.html [ ^ ]

它将显示一个示例powershell脚本,该脚本将从自定义查询中导出数据,将其保存到本地c盘和.csv文件。所有这些都是可配置的。


试试这个链接



http://stackoverflow.com/questions/15739215/export-sql-table-to-text-file-on-local-machine [ ^ ]

Hello All
I Want to Export Sql Table To text file
I do that by
exec master..xp_cmdshell ''bcp "Select * FRom Db..Table as t" queryout "C:\AA.txt" -c -T -SServer_Name ''
It do fine but it export result to server
I want to export this result to myPc not at server
Any Help Please.

解决方案

You can create a powershell script as your requirement and execute it. It will store your sqlserver data to your local or any share location. Just you take a basic idea about powershell if you have not. Then go the following site:
http://billfellows.blogspot.com/2011/03/powershell-export-query-to-csv.html[^]
It will show you a sample powershell script that will export data from a custom query and save it to local c drive and .csv file. All those are configurable.


Try this link

http://stackoverflow.com/questions/15739215/export-sql-table-to-text-file-on-local-machine[^]


这篇关于将Sql表导出到本地计算机上的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆