Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql scheduler

Author  Topic 

divan
Posting Yak Master

153 Posts

Posted - 2012-10-19 : 14:44:39
I have a step in my scheduler that is as follows

DECLARE @SQL VARCHAR(120)

--COPY A NEW ONE IN
SET @SQL = 'xp_cmdshell ' + CHAR(39) + 'COPY C:\Reports\Templates\TRIBUTE_DETAIL_IND.xls C:\Reports\TRIBUTE_DETAIL_IND.xls' + CHAR(39)
EXEC (@SQL)

I have the file that is looking for in the folder that I have assigned it to look into:TRIBUTE_DETAIL_IND.xls

but this step fails and the error is


Message
Executed as user: The process could not be created for step 7 of job 0x56FC8CF8E5D1084B99DCB56D98A901D5 (reason: The system cannot find the file specified). The step failed.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-10-19 : 15:14:25
1. Show us the output of @SQL via PRINT @SQL
2. Does that path exist on the actual database server or just your client machine?
3. If it exists on the database server, does the SQL Server service account have access to it? To verify, log into the database server using that account and see if you can open it.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

mandm
Posting Yak Master

120 Posts

Posted - 2012-10-19 : 15:15:43
Try this

SET @SQL = 'xp_cmdshell ' + CHAR(39) + 'COPY C:\Reports\Templates\TRIBUTE_DETAIL_IND.xls' + CHAR(39) + ' ' + CHAR(39) + 'C:\Reports\TRIBUTE_DETAIL_IND.xls' + CHAR(39)
EXEC (@SQL)

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-19 : 22:29:04
if its in client machine you might have to specify unc path instead

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

divan
Posting Yak Master

153 Posts

Posted - 2012-10-22 : 13:58:42
I went on the same machine and went into sql and ran the script and the file was copied.. the result of the PRINT @SQL IS

xp_cmdshell 'COPY C:\Reports\Templates\TRIBUTE_DETAIL_IND.xls C:\Reports\TRIBUTE_DETAIL_IND.xls'
Go to Top of Page
   

- Advertisement -