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
reddy
What exactly is it that you have a problem with? Just use cp_cmdshell and execute 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
|||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
>
|||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
|||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
>
|||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
>

No comments:

Post a Comment