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 |
|
ejadrum
Starting Member
3 Posts |
Posted - 2002-01-09 : 16:47:06
|
| OK, so I have never used bcp before and I believe I have the correct syntax, but I am getting an error that says....Line 1: Incorrect syntax near 'queryout'. This is what I got.Thanks in advance bcp "SELECT * FROM authors" queryout "c:\sql_test_file.txt" -SVader -Usa -P***** |
|
|
chadmat
The Chadinator
1974 Posts |
Posted - 2002-01-09 : 18:38:13
|
| Are you running this in Query Analyzer?BCP is a DOS utility.-Chad |
 |
|
|
izaltsman
A custom title
1139 Posts |
Posted - 2002-01-09 : 18:41:08
|
Your syntax looks ok to me. However, you need to remember that bcp is a command-line utility. In other words, your command will run as-is from the DOS prompt or a batch file. But if you want to run it from query analyzer (or from within a stored procedure, you are gonna have to wrap an xp_cmdshell around it. You would also need to specify the datatype switch(i.e. -n, -c, -w, or -N) or a format file (-f) to avoid the interactive mode.So the syntax would look something like: master..xp_cmdshell 'bcp "SELECT * FROM pubs..authors" queryout "c:\sql_test_file.txt" -SVader -Usa -P***** -N'Sniped again! Edited by - izaltsman on 01/09/2002 18:47:54 |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-01-09 : 18:47:36
|
| And if you want the whole table you don't need the select statement.If you don't want the whole table then I would suggest bcping in and out to views (one of the few times I recommend views).master..xp_cmdshell 'bcp pubs..authors out c:\sql_test_file.txt -SVader -Usa -P***** -N'==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy. |
 |
|
|
ejadrum
Starting Member
3 Posts |
Posted - 2002-01-10 : 14:04:45
|
| Aaaaaahhhhhhh!! Gotcha, ya I am trying to run it from within a stored procedure. See, I told you I was a newbie! Thanks for turning the light on. |
 |
|
|
|
|
|