Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server
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 31-Mar-13 21:13pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Comments
Mustafa Salman at 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 at 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 at 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 at 1-Apr-13 12:46pm
   
Sorry no idea about Visual Foxpro.
Mustafa Salman at 3-Apr-13 2:20am
   
Thank you very much
I do that
Thank again for your helpful link.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v2
Comments
Mustafa Salman at 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)

  Print Answers RSS
0 OriginalGriff 575
1 George Jonsson 285
2 Garth J Lancaster 280
3 Sergey Alexandrovich Kryukov 264
4 Maciej Los 250
0 Sergey Alexandrovich Kryukov 10,879
1 OriginalGriff 5,555
2 Maciej Los 5,534
3 CPallini 3,819
4 BillWoodruff 3,594


Advertise | Privacy | Mobile
Web02 | 2.8.141030.1 | Last Updated 1 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100