September 24, 2008 at 2:42 pm
I have found on the forums this code to output a .sql query (I have modifed for my needs):
sqlcmd -S ECOM-VS-01 -i "d:\sqlcode\backorder.sql" -o "\\temp-shed-40\public\backorder.csv" -s"," -h-1 -W
This command is called from a batch file. I want to have this automatically run daily.
I tried running from a SQL job and received the error "the system cannot find the file specified."
I tried running this from a Windows Scheduled task and nothing happened.
Any ideas would be appreciated.
ECOM-VS-01 is the SQL Server running SQL Server 2005.
D: is a local drive to the SQL server.
temp-shed-40 is a network server.
Jason Johnson
September 24, 2008 at 2:55 pm
the issue you are running into is the account SQL server is running under is not an account that has access to teh network. jobs run under the security context of a specific account, and not the person who created the job, or even who is running it manually.
you'll want to go to Control Panel >>Administrative Tools Services>> The specific SQL Server Instance(might be more than one)
You'll want to change the screen below to run under a login you create that would have access to the machine in question...so if you create a new user named SQLAdmin, and that user has access, that user could be used to start up the account and jobs run under that context would perform as expected.
Jason (9/24/2008)
I have found on the forums this code to output a .sql query (I have modifed for my needs):sqlcmd -S ECOM-VS-01 -i "d:\sqlcode\backorder.sql" -o "\\temp-shed-40\public\backorder.csv" -s"," -h-1 -W
This command is called from a batch file. I want to have this automatically run daily.
I tried running from a SQL job and received the error "the system cannot find the file specified."
I tried running this from a Windows Scheduled task and nothing happened.
Any ideas would be appreciated.
ECOM-VS-01 is the SQL Server running SQL Server 2005.
D: is a local drive to the SQL server.
temp-shed-40 is a network server.
Jason Johnson
Lowell
September 25, 2008 at 7:18 am
I'm not very familiar with Active Directory.
SQL Server is running under a domain account on the network. This account should have access to network resources.
How can I be sure?
Jason
September 25, 2008 at 12:09 pm
Try mapping a drive to the \\temp-shed-40\public\location as the user account (i.e. 'connect using a different user name' and see if you can manually copy files there.
Also, where is your sql file actually stored? Is d:\sqlcode\ a valid location on the server running the SQL agent?
September 25, 2008 at 12:19 pm
I am unable to copy to the \\temp-shed-40 location either as a mapped drive or direct connection as a different domain user.
D: is a local drive to the SQL server and SQL Agent is running on that same server.
?
September 25, 2008 at 12:20 pm
That's your issue, the account running the job needs write access to the location you are writing to.
September 25, 2008 at 12:52 pm
My account, ECOMSA01, is member of Domain Users.
Domain Users has write-access to this network location.
Am I missing something?
September 26, 2008 at 7:22 am
Since the account that SQL Agent is a member of a group that has write access to the network location, the SQL job should be able to write to the file.
Any ideas?
Jason Johnson
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply