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 2005 Forums
 Transact-SQL (2005)
 Error in using xp_cmdshell

Author  Topic 

d@nish
Starting Member

3 Posts

Posted - 2008-12-11 : 10:40:36
I am using following command:
exec master..xp_cmdshell 'bcp "select * from cab.useraudit" queryout "c:\test.xls" -c -T'

Executing this command gives following error:

"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 connections."

What might be wrong?

X002548
Not Just a Number

15586 Posts

Posted - 2008-12-11 : 11:02:01
exec master..xp_cmdshell 'bcp "select * from cab..useraudit" queryout "c:\test.xls" -c -T'

????

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

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

d@nish
Starting Member

3 Posts

Posted - 2008-12-11 : 11:04:46
quote:
Originally posted by X002548

exec master..xp_cmdshell 'bcp "select * from cab..useraudit" queryout "c:\test.xls" -c -T'

????



I need to export this query result to the mentoned excel file. I am generating similar statement dynamically in a stored procedure.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2008-12-11 : 11:09:06
try supplying the dname.owner.tablename



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

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

d@nish
Starting Member

3 Posts

Posted - 2008-12-11 : 11:13:25
I have already tried that. That doesnt helps.
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-12-11 : 12:41:23
quote:
Originally posted by d@nish

I have already tried that. That doesnt helps.



Does it give you an error if you run this ?

exec master..xp_cmdshell 'bcp "select * from sysobjects" queryout "c:\test.xls" -c -T'


If not, then follow the instructions here and then run your original query-
http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2008-12-11 : 13:30:13
Also why do you need queryout when doing select *????



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

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -