[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

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?
0
sib_user
Asked:
sib_user
1 Solution
 
Chris MangusDatabase AdministratorCommented:
Add -S parameter and specify your server name.
0
 
sib_userAuthor Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now