Solved

xp_cmdshell and remote share on windows box

Posted on 2012-03-28
2
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:
Ramesh Babu Vavilla 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TSQL recursive CTE challenge... 8 47
SQL trigger 5 50
What is this datetime? 1 33
Many to one in one row 2 48
There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 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