January 19, 2010 at 9:57 pm
Can anyone tell why command 1 is working while command 2 is not working?
1. exec xp_cmdshell 'copy C:\Test.xml c:\test.xls'
2. exec xp_cmdshell 'copy C:\[Documents and Settings]\Lucky\[My Documents]\CKM\Test.xml c:\test.xls'
-Lk
January 19, 2010 at 10:29 pm
exec xp_cmdshell 'copy "C:\Documents and Settings\Lucky\My Documents\CKM\Test.xml" "c:\test.xls"'
--Jeff Moden
Change is inevitable... Change for the better is not.
January 19, 2010 at 10:33 pm
depending in which OS this is running on as well, you will need to use the file path in this format:
exec xp_cmdshell 'copy C:\Docume~1\Lucky\MyDocu~1\CKM\Test.xml c:\test.xls'
that might do the trick 🙂
January 19, 2010 at 10:45 pm
This was removed by the editor as SPAM
January 20, 2010 at 12:34 am
I find that running batch files through xp_cmdshell is a much better way to perform dos operations, also you might want to look into forfiles.
Remember
Without Change something sleeps inside of us that seldom awakens, the sleeper must awaken!!
January 20, 2010 at 2:35 am
Thanks one and all.
lk
June 16, 2016 at 7:05 am
Try this query...,before set configures of xp_cmdshell
declare @aaa varchar(40)
set @aaa=(select @@servername)
declare @bbb nvarchar(500)
set @bbb='select name from sys.databases'
exec(@bbb)
declare @BCP nVarchar(500)
set @BCP ='bcp "'+@bbb+'" queryout "D:\output.txt" -c -t, -T -S '+@aaa+''
EXEC master..xp_cmdshell @BCP
June 16, 2016 at 8:25 am
Mr J (1/20/2010)
I find that running batch files through xp_cmdshell is a much better way to perform dos operations, also you might want to look into forfiles.
Kindred spirit here on both of those. FORFILES was a fairly "recent" and welcome addition to the command line.
--Jeff Moden
Change is inevitable... Change for the better is not.
June 16, 2016 at 8:34 pm
Jeff Moden (6/16/2016)
Mr J (1/20/2010)
I find that running batch files through xp_cmdshell is a much better way to perform dos operations, also you might want to look into forfiles.Kindred spirit here on both of those. FORFILES was a fairly "recent" and welcome addition to the command line.
That was recent. I've just always used "for /f" command to loop through files.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply