Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

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.
 
Share this answer
 
Comments
Mustafa Salman 1-Apr-13 6:01am    
Thank you for your responce
but I want Direct Export from server to local PC
someone Suggest using UNC
but I have no idea to do that.
S. M. Ahasan Habib 1-Apr-13 6:07am    
you can change in powershell connection string and run it from your local. It will fetch data from remote database server based on your connection string and store it to your local pc. You just go the link above create a powsershell script (.ps1 extention) and dump that code to your file and update with your connection string. Then go to windows powershell tool, execute that see the result. As simple as that. I think you will impress with power shell power.
Mustafa Salman 1-Apr-13 7:22am    
Hello again

I followed above link
and do what he do
Now I wonder how include it at my application
Using Visual Fox Pro.
Any Help ?
S. M. Ahasan Habib 1-Apr-13 12:46pm    
Sorry no idea about Visual Foxpro.
Mustafa Salman 3-Apr-13 2:20am    
Thank you very much
I do that
Thank again for your helpful link.
 
Share this answer
 
v2
Comments
Mustafa Salman 1-Apr-13 4:19am    
No Result at your link :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900