Saturday, February 25, 2012

copy a file with xp_cmdshell

hi friends,
how to move a file from client to server through xp_cmdshell
please provide the script
thanks
reddyWhat exactly is it that you have a problem with? Just use cp_cmdshell and ex
ecute the desired copy
command, where you specify the paths to the files using UNC naming, like:
EXEC master..xp_cmdshell 'COPY \\machine1\sharename\filename.txt \\machine2\
sharename\filename.txt'
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:7D3AFFFE-C388-4B3A-929A-211B5DD5A419@.microsoft.com...
> hi friends,
> how to move a file from client to server through xp_cmdshell
> please provide the script
> thanks
> reddy|||hi tibor,
i used the same command.
the error is Logon failure: unknown user name or bad password.
please help
thanks
reddy|||If copying to/from a remote drive, check that your SQL Server service is
started using a domain user account, not the Local System account, and
ensure that the right permissions are granted to this domain user to access
that remote drive.
You can check this by running the dir command from within xp_cmdshell e.g.
xp_cmdshell 'dir \\network share name'
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backups? Try MiniSQLBackup
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:14F3F85F-691A-4CD4-BA21-352F2176104A@.microsoft.com...
> hi tibor,
> i used the same command.
> the error is Logon failure: unknown user name or bad password.
> please help
> thanks
> reddy
>|||hi friends,
i tried all your suggestions.but not working for me.
i am getting the follwing errors
if i use copy
EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
Invalid drive specification
if i use xcopy
EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
Logon failure: unknown user name or bad password.
plase suggest if any otherways are there to copy the files
thanks®ards
reddy|||Check your SQL Server service account (go to Administrative Tools /
Services). Is it started using the Local System account? If it is, use a
domain user account instead.
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backups? Try MiniSQLBackup
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:1F112BD9-1970-4144-B6B0-994881CF46C9@.microsoft.com...
> hi friends,
> i tried all your suggestions.but not working for me.
> i am getting the follwing errors
> if i use copy
> EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
> Invalid drive specification
> if i use xcopy
> EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
> Logon failure: unknown user name or bad password.
> plase suggest if any otherways are there to copy the files
> thanks®ards
> reddy
>|||If this is a cut-n-paste of the actual code then it looks like you are
missing a ":" colon after the d in d\upd.txt
Should that read d:\upd.txt ' If not then it is a relative path are you
really sure it is there? I assume it is missing the colon based on the
error you received "Invalid drive specification"
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:1F112BD9-1970-4144-B6B0-994881CF46C9@.microsoft.com...
> hi friends,
> i tried all your suggestions.but not working for me.
> i am getting the follwing errors
> if i use copy
> EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
> Invalid drive specification
> if i use xcopy
> EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
> Logon failure: unknown user name or bad password.
> plase suggest if any otherways are there to copy the files
> thanks®ards
> reddy
>

No comments:

Post a Comment