Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

xp_cmdshell and remote share on windows box

Posted on 2012-03-28
2
Medium Priority
?
309 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 800 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:
Ramesh Babu Vavilla earned 1200 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

972 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