Solved

Errors exporting data from sql server.

Posted on 2010-09-14
2
219 Views
Last Modified: 2012-05-10
I am attempting to export data from an sql server database to a text file using the example shown in this link: http://www.mssqltips.com/tip.asp?tip=1633.

I change the command to:
EXEC xp_cmdshell 'bcp "SELECT * FROM [CensusData].[dbo].[MainQuestionnaire$]" queryout "C:\bcptest.txt" -T -c -t,'

However I am getting the error:
Error =[Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid object name 'CensusData.dbo.MainQuestionnaire$'.  (see image)  

But when I run the query by itself i.e.:
SELECT * FROM [CensusData].[dbo].[MainQuestionnaire$ all rows are returned.

What changes do I need to make to allow the EXEC xp_cmdshell command to run without errors?
0
Comment
Question by:sib_user
2 Comments
 
LVL 17

Accepted Solution

by:
Chris Mangus earned 500 total points
ID: 33677979
Add -S parameter and specify your server name.
0
 

Author Comment

by:sib_user
ID: 33678006
cmangus,

Your answer got me past that error and I am awarding you the full points.  But there is another error:
"Unable to open bcp host data file".

I shall post it in another question so that you or some other expert can have a go at it.

Thank you very much.

0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now