Click here to Skip to main content
11,805,316 members (65,191 online)
Rate this: bad
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
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:[^]
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.
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
Please Sign up or sign in to vote.

Solution 1

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 315
1 Sergey Alexandrovich Kryukov 200
2 Richard Deeming 200
3 CPallini 160
4 CHill60 150
0 OriginalGriff 3,265
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web02 | 2.8.151002.1 | Last Updated 1 Apr 2013
Copyright © CodeProject, 1999-2015
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