Solved

xp_cmdshell and remote share on windows box

Posted on 2012-03-28
2
302 Views
Last Modified: 2012-03-29
Hi,
Does xp_chdshell works fine with remote server share like samba,dfs etc?
The services are started by windows system account.

-  xp_cmdshell to extract data
EXEC xp_cmdshell 'bcp "SELECT * FROM test1 " queryout "\\server\share1\test1.txt" -T -c -t,'

Thanks
0
Comment
Question by:crazywolf2010
2 Comments
 
LVL 40

Assisted Solution

by:lcohan
lcohan earned 200 total points
ID: 37778108
As long as the SQL login running the command above has SUFFICIENT rights to that share it should not be a problem. We use samba server for our digital files and perform "imports/exports" of these digital files via SQL using similar method - we use SQLCMD utility not BCP.

http://msdn.microsoft.com/en-us/library/ms162773.aspx
0
 
LVL 10

Accepted Solution

by:
sqlservr earned 300 total points
ID: 37781299
yes it works but your bcp command needs the

-S Servername
-U Username
-P password

bcp DatabaseName.dbo.tableName out \\sqlservr\test.dat -S sqlservr\MSSQLSERVER05 -U admin
-P admin -n -T


is xp_cmdshell enable in  sql server,
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.

821 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