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 |
|
nguyenl
Posting Yak Master
128 Posts |
Posted - 2008-03-21 : 13:06:48
|
| bcp.exe northwind..products out "c:\nw_products.txt" –c -TI am running this line of code, but I get an error. The error is:Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near '.'.why? Please help...Thanks |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-03-21 : 13:53:15
|
| Where are you running the command?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
nguyenl
Posting Yak Master
128 Posts |
Posted - 2008-03-21 : 15:44:16
|
| I am running it in Sql analyzer 2005. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-03-21 : 15:48:09
|
| what's Sql analyzer 2005?_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
nguyenl
Posting Yak Master
128 Posts |
Posted - 2008-03-21 : 16:20:40
|
| Sorry menat query analyzer in Sql 2005 |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-03-21 : 16:55:17
|
| You need to either run the command in a cmd window (Start..Run..type in cmd and hit enter) or via xp_cmdshell. You can not run that command directly in Query Analyzer without xp_cmdshell.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2008-03-23 : 22:48:54
|
The real problem is that you copied the example from Books Online and it has a super-secret decoder-ring error in it. If you look at the "-c" in the command, the dash is actually larger than the dash in "-T"... that's because it's incorrectly an "em" dash. Replace that dash with a correct one, and you should be ok (compare below)...bcp.exe northwind..products out "c:\nw_products.txt" –c -T (incorrect copied version)bcp.exe northwind..products out "c:\nw_products.txt" -c -T (corrected version)After you fix that, you may end up with another problem... I believe you'll need to add the "-S" parameter (servername\instance name)From T-SQL, this works on my machine... (server name\instance name changed... you'll need to, as well)EXEC Master.dbo.xp_CmdShell 'BCP "Northwind.dbo.Products" out "c:\NW_Products.txt" -c -T -S"server\instance"'If you're trying to run it from a Cmd window, then just use the BCP command without the T-SQL... like this...BCP "Northwind.dbo.Products" out "c:\NW_Products.txt" -c -T -S"server\instance"--Jeff Moden "Your lack of planning DOES constitute an emergency on my part... SO PLAN BETTER! ""RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row"For better, quicker answers, click on the following... [url]http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url] |
 |
|
|
|
|
|
|
|