Link to home
Start Free TrialLog in
Avatar of sib_user
sib_user

asked on

Errors exporting data from sql server.

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?
ASKER CERTIFIED SOLUTION
Avatar of Chris Mangus
Chris Mangus
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sib_user
sib_user

ASKER

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.