Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
robert693
Starting Member
42 Posts |
Posted - 2009-08-18 : 14:57:38
|
| I have a query that pulls data drom several tables. How can I dump the data to a flat file? Is the bcp Utility what I would use?Thank you for your help! |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-08-18 : 16:43:34
|
exactly. here's a samplebcp "YOUR SELECT QUERY HERE" queryout f:\datafile.txt -c -SserverNameHere -T the stuff in red you need to change |
 |
|
|
robert693
Starting Member
42 Posts |
Posted - 2009-08-20 : 11:32:23
|
| Do I run this from the command prompt? |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-08-20 : 12:54:41
|
| yes |
 |
|
|
shebert
Yak Posting Veteran
85 Posts |
Posted - 2009-08-20 : 13:01:28
|
| Couldn't you just set query results to file in query analyser? |
 |
|
|
robert693
Starting Member
42 Posts |
Posted - 2009-08-21 : 14:14:43
|
| How can I do it in the query analyzer? I am in SQL Server 2005, I think that the analyzer is the query building area in this version. |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-08-21 : 22:47:37
|
| you could so it with SSMS, but don't. use BCP. SSMS would add headers, footer and not be formatted properly for importing later |
 |
|
|
Mangal Pardeshi
Posting Yak Master
110 Posts |
Posted - 2009-08-22 : 08:58:35
|
| u can use the XP_CmdShell, execute following in SSMSXP_CmdShell 'bcp "YOUR SELECT QUERY HERE" queryout f:\datafile.txt -c -SserverNameHere -T'Mangal Pardeshihttp://mangalpardeshi.blogspot.com |
 |
|
|
|
|
|