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 |
|
newty25
Starting Member
21 Posts |
Posted - 2002-02-01 : 16:18:34
|
I am attempting to 'bcp' to export data from my MS SQL Db without success. Here is what I have written so far... bcp "SELECT * FROM table" out title.txt -c -Sservername -Uusername -Ppassword The error that I get looks like this...Cannot use the OUTPUT option when passing a constant to a stored procedure. Does anyone have any suggestions? |
|
|
chadmat
The Chadinator
1974 Posts |
Posted - 2002-02-01 : 16:39:50
|
| You need to either specify a table (Which makes sense since you are doing a select *) or use 'queryout' rather than 'out'.-Chad |
 |
|
|
butlermi_11
Starting Member
10 Posts |
Posted - 2002-02-01 : 16:41:45
|
| Give this a shot bcp dbname..tablename out publishers.txt -c -Sservername -Uusername -Ppassword |
 |
|
|
newty25
Starting Member
21 Posts |
Posted - 2002-02-01 : 17:06:36
|
Chad wrote...quote: You need to either specify a table (Which makes sense since you are doing a select *) or use 'queryout' rather than 'out'.
I tried using 'queryout' and it gives me this errorLine 1: Incorrect syntax near 'queryout'. Anymore ideas??? |
 |
|
|
izaltsman
A custom title
1139 Posts |
Posted - 2002-02-01 : 17:54:35
|
| You are running it in Query Analyzer, aren't you? bcp is actually a command line utility, so you can either run your command from a DOS window, or, if you want to run it from QA or from within a stored procedure, you'll have to wrap it in xp_cmdshell like so: exec master..xp_cmdshell 'bcp "SELECT * FROM table" queryout title.txt -c -Sservername -Uusername -Ppassword'Edited by - izaltsman on 02/01/2002 17:55:50 |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-02-01 : 18:54:37
|
| exec master..xp_cmdshell 'bcp table out title.txt -c -Sservername -Uusername -Ppassword'You might also want to use a view rather than the table as it makes the bcp a bit more flexible but less complicated than using a query.==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy. |
 |
|
|
newty25
Starting Member
21 Posts |
Posted - 2002-02-03 : 15:29:07
|
| You're exactly right... it worked just fine after I used it from the command prompt. Thanks alot!!! |
 |
|
|
|
|
|