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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Trying to use xp command shell

Author  Topic 

itmasterw
Yak Posting Veteran

90 Posts

Posted - 2010-10-22 : 09:01:22
Hi,
I am trying to use xp_cmdshell, which I have used on th ejob all the time in this way, but for some reason is not working on my computer. Below is the error mesage that I am getting, but I am not understanding what it is telling me or what to do about it. I am using SQL Server Express 2008, and my machine is Windows 64 bit processing, is case this has something to do with it. If you have any ideas what I can do to get this work I would appreaciate it.
Thank you

SQLState = 08001, NativeError = 126
Error = [Microsoft][SQL Native Client]VIA Provider: The specified module could not be found.
NULL
SQLState = 08001, NativeError = 126
Error = [Microsoft][SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connecti
ons.
SQLState = S1T00, NativeError = 0
Error = [Microsoft][SQL Native Client]Login timeout expired
NULLMy code:

my code:
This is using the the Northwind database
exec Master..xp_cmdshell 'bcp " Select * from dbo.Employees " queryout C:\TestEd.xls -T -c'


ITM

Sachin.Nand

2937 Posts

Posted - 2010-10-22 : 14:37:30
Seems like you will have to enable xp_cmdshell on your server.



PBUH

Go to Top of Page

itmasterw
Yak Posting Veteran

90 Posts

Posted - 2010-10-22 : 19:10:22
quote:
Originally posted by Sachin.Nand

Seems like you will have to enable xp_cmdshell on your server.



PBUH





Yes it looks like I have to turn on something comand shell or repote server, but how do you do that?


ITM
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-10-23 : 01:01:55
EXEC sp_configure 'show advanced options', 1
GO

RECONFIGURE
GO

EXEC sp_configure 'xp_cmdshell', 1
GO

RECONFIGURE
GO

PBUH

Go to Top of Page

itmasterw
Yak Posting Veteran

90 Posts

Posted - 2010-10-23 : 20:59:24
Hi,
I ran this but I still get the same error, do you have any other ideas what I might be able to do? I appreciate your help I have been searching for a solution for week now.
thank you

ITM
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-24 : 00:49:08
You haven't specified the database name in the bcp query. Use DatabaseName.dbo.Employees.

You also haven't specified which server to use. You'll need to add the -S parameter.

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

Subscribe to my blog
Go to Top of Page

itmasterw
Yak Posting Veteran

90 Posts

Posted - 2010-10-24 : 13:38:38
I got it to work, thanks for your help.

ITM
Go to Top of Page
   

- Advertisement -