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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 bcp utility problem

Author  Topic 

ConnieXujuan
Starting Member

48 Posts

Posted - 2012-03-25 : 23:16:19
Hey folks,

I was using:

bcp DatabaseName..tableName
in "C:\Users\Connie\Desktop\test.txt" -c -T

but it keeps given me the below error message:

Msg 102, Level 15, State 1, Line 39
Incorrect syntax near 'bcp'.

I really cann't see any wrong with the syntax.

Could anyone please let me know what's wrong here?

Thanks a lot!

Connie

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-03-26 : 05:15:16
Your example needs to be executed on (DOS) command line.
It looks like you have tried to run it in a query window.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

ConnieXujuan
Starting Member

48 Posts

Posted - 2012-03-26 : 07:45:07
Thanks a lot!!
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-26 : 09:14:17
can you execute xp_cmdshell?

Plus, I believe you think it will grab the file from your desktop.

It will be looking at the server drives



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-26 : 13:10:07
you should enable xp_cmdshell if its not already enabled. By default it will be in disabled state

EXEC sp_configure ‘show advanced options’, 1

GO

—- To update the currently configured value for advanced options.

RECONFIGURE

GO
EXEC sp_configure ‘xp_cmdshell’
GO

this will display if its set ot not

use below to set it

—- To enable the feature.

EXEC sp_configure ‘xp_cmdshell’, 1

GO
RECONFIGURE
GO


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-03-26 : 13:12:11
quote:
Originally posted by X002548


Plus, I believe you think it will grab the file from your desktop.

It will be looking at the server drives




It actually will look at the files from the desktop if OP uses cmd from the desktop.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-03-26 : 13:13:25
quote:
Originally posted by visakh16

you should enable xp_cmdshell if its not already enabled. By default it will be in disabled state




Only enable it if you need it. It is disabled for a reason. Enabling it for bcp is kinda pointless when you can run bcp from the desktop.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-26 : 13:19:22


but of course





Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

ConnieXujuan
Starting Member

48 Posts

Posted - 2012-03-27 : 01:18:32
Thanks guys!! very much appreciated!! It is working now~~
Go to Top of Page
   

- Advertisement -