Not able to run the SSIS package in SQL Server Agent Job in SQL 2012
Hi,
I scheduled a job (SQL SERVER AGENT) which will call my SSIS package. This package will execute 5 packages in loop.
When I execute this job I am getting error as below
============================================================
Started : 12:30:19 PM
Error : 2014-01-23 12:30:20.37
Code : 0xC00220EC
Source : Execute Package Task
Description : Error 0x80070005. Failed to create an instance of empty child package.
The Distributed Component Object Model (DCOM) configuration or the installation of SQL Server Integration Services,
may be corrupted on your machine. End Error
Error : 2014-01-23 12:30:20.37
Code : 0xC00220DE
Source : Execute Package Task
Description : Error 0x80070005 while loading package file "D:\SSIS\RetailMobileApp\Staging_Pkg\stg_Category_Master.dtsx". Access is denied.End Error
DTExec : The package execution returned DTSER_FAILURE (1).
Started : 12:30:19 PM
Finished : 12:30:20 PM
Elapsed : 1.123 seconds.
The package execution failed.
The step failed.
============================================================
In the STEPS I have selected as follows:
Type : SQL Server Integration Services Package
Run as: SQL Server Agent Service Account
Package Source: File System
What config I need to check here ? This job is not able to access the package stored in the folder.
Sridhar
Thanks for your reply. I had created credentials and used this while creating the Proxy account. With the Proxy account I am able to execute the Job Successfully. Concern here is I used my NT account to create this Proxy. Suppose If I left from the
current project if some one is coming to this project later they need to change the credential with their NT account and run the JOB? Is this right way or we an create any other account in common? If so how?
Sridhar
Similar Messages
-
SSIS running through SQL Server agent Job Fails --SQL Server 2012
Hi All,
I am getting the below error.
Executed as user: sak\thiru. ...ion 11.0.2100.60 for 64-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 3:31:17 PM Error: 2014-03-07 15:32:22.46 Code: 0xC0202009 Source: CommonDataSource
Connection manager "TESTDB" Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0"
Hresult: 0x80004005 Description: "Login timeout expired". An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "A network-related or instance-specific
error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.".
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "Named Pipes Provider: Could not open a connection to SQL Server [53]. ". End Error Error:
2014-03-07 15:32:43.58
The package execution fa... The step failed.
I checked namedpipes, ports,services, SqlBrowser all are running fine.
share your views.
Thanks
Thiru
ThiruHi Thiru,
The error messages are rather general and the issue may occur due to various causes. You can check the “Connect Time” setting of the Connection Manager "TESTDB", and increase its timeout value.
If the issue persists, maybe it occurs because the Windows Firewall or certain anti-virus software blocks the RPC dynamic range of TCP Ports between SQL Server and Domain Controllers. In this case, temporarily disable third party anti-virus software, or
configure RPC dynamic port allocation to work with firewalls referring to the following KB article
http://support.microsoft.com/kb/154596.
In addition, the issue may be related to the SQL Server that the OLE DB Source adapter connects to. You can check the SQL Server log to see if any error occurs at that time.
Hope this helps.
Regards,
Mike Yin
TechNet Community Support -
Execution of a batch file within SSIS fails in Sql Server Agent Job
Hi All,
I have an SSIS Package, which simply runs a batch file , the code for the batch file is
MOVE \\cambosnapp01\Claims\Analytics\NICB\CurrentAlerts\* \\cambosnapp01\Claims\Analytics\NICB\AlertsArchive
If i run the SSIS package manually it runs fine and moves all the files, however if i run the package through a Sql Agent Job it fails with the following error
The directory "\\Cambosnapp01\Claims\Analytics\NICB" does not exist
This is where the batch file is located, i am not able to understand if the SSIS package is running fine then why not the sql agent job?
I also tried to create a sql agent job using Operating System(CmdExec) and i copied my batch file code in the command i am running it as SQL Server Agent Service Account , and here it fails as
Executed as user: CAMELOT\svcDW. Access is denied. Process Exit Code 1. The step failed
Does this mean this user doesnt have the rights to excute a batch file? how did this user even come up i am not running it from this user i am running it from SQL Server Agent Service Account . I dont know who is that user and if he even has the rights to
execute a batch file.
Can someone please help me with any solution for this? either first way or second way anything works fine for me.
ThanksHi SQLDEV,
According to your description, you are experiencing the issue "The directory "\\Cambosnapp01\Claims\Analytics\NICB" does not exist" when run the SSIS package
in SSMS by using SQL Server Agent, right?
In your scenario, since you can run the package in SSDT manually. So as per my understanding, the issue can be caused by that the Services Account of your SQL Server Agent do not have the permission on that folder. To avoid this issue, you can set the folder
permission for your SQL Server Agent account or change the services account to an account who have the corresponding permission. Please refer to the link below to see the details.
https://msdn.microsoft.com/en-us/library/bb727008.aspx
https://msdn.microsoft.com/en-us/library/ms345578.aspx
Regards,
Charlie Liao
If you have any feedback on our support, please click
here.
Charlie Liao
TechNet Community Support -
Am not able to run the java program - pls help
1. I installed java in the below path
c:\program files\java\jdk1.5.0
c:\program files\java\jre1.5.0
I set the path in
User variable i. variable name: path
ii. variable value: c:\program files\java\jdk1.5.0\bin
when I compile it in command prompt-applying javac ? it performed successfully-shows
options like ?g create all debug info, -g : new Generate no debug info etc.,
But am not able to run the file. It shows error msg.
2. I specified the same name for file name & class name.
3. Java <class name>
Exception in thread ?main?java.lang.NoclassDeffoundError: <class name>
4. Java ?cp <class name>
Unrecognized option: -cp.<classname>
Could not create the Java Virtual Machine
5. Java ?classpath . <classname>
Exception in thread ?main?.java.lang.unsupported classversionError: <classname>
<unsupported major.minor version 49.0
at java.lang.classloader.defineclass0<native method>
at java.lang.classloader.defineclass<unknown source>
--and many listed below?
6. Java ?classpath c:\program files\java\jdk1.5.0\bin <class name>
Exception in thread ?main?java.lang.NoclassDeffoundError: <class name>
7. I re-installed the java, but still the problem continuing.
pls help... its very urgentIs the java class you compiled/calling in the default package? If it is not, you will have to call it by the fully qualified name.
e.g.
package com.mycompany.myproject;
public class MyClass {
public static void main(String[] args) { }
}This would be called as "Java com.mycompany.myproject.MyClass" and must contain a main method with signature as above.
You would have to call this from folder where the compiled classes are located. If using package, you would call from directory at level of top most package so com folder in this example as Java will look at each package name in qualified name and try to traverse directories with those same names to get to .class file matching class name specified. To avoid this, your newly compiled .class files must also be in your classpath.
Hopefully that helps.
--Kevin -
Not able to run the Jdeveloper Pages in Local Machine
Dear All,
I am developing Custom OAF Pages in R12. while am not able to run the page in Local Machine Currently i am using Remote VPN. same page i import into server am able to run in Application.
The error says:
1, Increae the time limit bye setting the JRAD.RUNREG.TIMEOUT Parameter in ide.parameters file loacted in System directory.
I found the file . am not able to find the JRAD.RUNREG.TIMEOUT Parameter option
2, Check the Host Name in the Preferances, Under Embeded OC4J.
I Verified same and using the Default Local IP Address.
I am using Jdeveloper Version : p8431482_R12_GENERIC.zip
Please help me. I approciate before
Thanks
Venkat Reddy Pulichintha
00971502644919
[email protected]Dear Gaurav,
Thanks for you quick replay
For this Patch number (p8431482_R12_GENERIC.zip), there is no (JAVA Options: remove this statement: -DFND_JDBC_STMT_CACHE_SIZE=200 -DCACHENODBINIT=true)
Please guide me furthe steps. any other settings requird.
Thanks
Venkat Reddy Pulichintha
00971502644919
[email protected] -
Hi Team,
I am running a sql server job which is loading data to a sharepoint document library.File is an excel format and is getting loaded
when executed through SSDT solution .But when i am using an SQL Agent job to pick up the file it doesnt get the path and agent job fails with the error "Failed to acquire connection".I have deployed the SSIS Package through SQL Server 2012 deployment
methodologies.
I am not able to trace the error of loading data from a sharepoint library.library. Sql agent jobs works fine when i give local path.The
account which is running the sql agent job is the same who has access to document library.I also tried to run the job through proxy account. I am using a xml configuraion to store my credentials.I am able to palce the same file to a network drive in the same
server through sql server agent job. The only problem is when I am trying to load the file to a sharepoint folder.
Thanks,
Arsa..Is that the WebDAV method that you are suggesting here to map the n/w drive?
Its kind of webdav but you will be using windows nw drive to store data
yes, I am able to create the file to D: , but didn't check with the C:.
Try with c:, as c: require special permisssions
If this helped you resolve your issue, please mark it Answered -
Error while executing SSIS package which contains Script component through SQL Server Agent Job
Hello All,
I have written one SSIS 2012 package which is fetching records from CSV and put it into staging DB and from staging DB , using SSIS script component task, I am inserting data into Dynamics CRM. So far it is working fine when
I manually execute SSIS package.
but when I run the SSIS package using SQL server agent job, I encounter below error. After seeing below error at step "Insert TLM Headers Script Component " I understand that it is failing at script component which I have used in SSIS package,
but I am not sure what is the cause behind that? please advise.
Error:
Executed as user: domain\user account. Microsoft (R) SQL Server Execute Package Utility Version 11.0.5556.0 for 64-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 1:21:41 PM Error: 2015-02-25
13:21:45.94 Code: 0xC0047062 Source: Insert TLM Headers Script Component [205] Description: System.ServiceModel.FaultException: The server was unable to process the request due to an internal
error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to
the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs. Server stack trace: at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message
reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.HandleUserException(Exception
e) at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.ProcessInput(Int32 inputID, PipelineBuffer buffer) at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostProcessInput(IDTSManagedComponentWrapper100
wrapper, Int32 inputID, IDTSBuffer100 pDTSBuffer, IntPtr bufferWirePacket) End Error Error: 2015-02-25 13:21:45.94 Code: 0xC0047022 Source: Insert TLM Headers SSIS.Pipeline
Description: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Script Component" (205) failed with error code 0x80131501 while processing input "Input 0" (215). The identified component returned an error
from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure. End Error
DTExec: The package execution returned DTSER_FAILURE (1). Started: 1:21:41 PM Finished: 1:21:45 PM Elapsed: 4.009 seconds. The package execution failed. The step failed.
Thanks
Pankajdomain\user account has not proper rights
That being said, often SSIS jobs require a proxy to be runnable and this is how you make one up
http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
Arthur
MyBlog
Twitter -
SSIS Package Fails when Scheduled as a SQL Server Agent Job
I have an SSIS package that runs without any problems when executed through BIDS.
However, when I schedule the SSIS as an Agent job, it fails completely or part way through. When it partially runs, the part that it is failing on is a Script Task that moves the source data file to an archive folder (on the same server).
I have tried using my domain account as the owner of the job, then the job fails straight off and I get an error:
Unable to determine if the owner (Domain\MyID) of job JobName has server access (reason: Could not obtain information about Windows NT group/user 'Domain\MyID'
If I change the owner to the 'sa' account , then the job partially runs, but then fails because 'sa' is a SQL account and does not have access to the filesystem.
I have managed to get it to work by using the SQL2008_Local account and granting modify permissions to the affected folders.
My question is - what is the advised way of doing this?
Thanks
GaryHi Garyv.King,
When you see a SSIS package fails running in a SQL Agent job, you need to first consider the following conditions:
1. The user account that is used to run the package under SQL Server Agent differs from the original package author.
2. The user account does not have the required permissions to make connections or to access resources outside the SSIS package.
For more detailed information about the issue, please following this KB article:
An SSIS package does not run when you call the SSIS package from a SQL Server Agent job step
http://support.microsoft.com/kb/918760
You can check SQL Server Agent’s activity logs, Windows Event logs and SSIS logs to get more clues. Also the tool Process Monitor is helpful to track the cause of registry or file access related issues.
The following 4 issues are common encountered in the SSIS forum.
1. The package's Protection Level is set to EncryptSensitiveWithUserKey but your SQL Server Agent service account is different from the SSIS package creator.
2. Data source connection issue.
3. File or registry access permission issue.
4. No 64-bit driver issue.
For more information about it, please see:
How do I troubleshoot SSIS packages failed execution in a SQL Agent job:
http://social.technet.microsoft.com/Forums/en-US/sqlintegrationservices/thread/e13c137c-1535-4475-8c2f-c7e6e7d125fc
Thanks,
Eileen -
SQL SERVER AGENT JOB ERROR - SSIS PACKAGE
Hi ,
I have a SQL server agent job which runs SSIS package as the daily job. The SSIS package contains multiple child package. Its a master package which calls other SSIS package. The master package calls 23 SSIS packages, few of the packages runs in parallel.
I am getting the below 2 different errors more frequently. It fails only in the production server, I scheduled the job in UAT server, it did not fail. Also when we run the master package with out sql agent job, it did not fail.
Error 1 :
R6025 - pure virtual function call. The return value was unknown. The process exit code was 255. The step failed.
Error 2 : The step did not generate any output. The return value was unknown. The process exit code was -1073741819. The step failed.
We tried browsing for the answers ,no luck. It failing in live , so we need to run the package manually in live server every time.
Please help me to resolve this issue. Thanks in advance.
Regards,
Dhivya SivakumarHi Vijeth,
Thanks for your reply.
1) Run the Package manually and check whether it runs successfully. -
No Failures. Package completed succesfully
2) If Step 1 is successful,
a) Point the same package to the UAT database and run it and check whether it runs successfully or not. -
We tried to schedule the package almost for 1 month. No failures in UAT.
b) In UAT database, point to the Production database and run the package. - I am not sure, if i can do this.I will try and let you know the result.
These steps will help us identify whether the problems lies within the package or the Environment.
3) Run the Package manually in production Environment using dtexec utilily. -
No Failures. Success.
4) Check the ID used to run the SQL Agent job and modify to an account with elevated permissions or GRANT more permissions to the existing ID. -
The account used currently is having all the privileges. Its the most powerful user in live DB.
Regards,
Dhivya S -
I've seen some conflicting things in terms of dynamic Excel commands running in a SSISDB Package and a scheduled SQL Server Agent Job...things like that it's not supported...that it won't work...etc...
It's a pretty simple script...to open up a .xlsx file and save it as a .xls file. I am trying to be proactive here and the reason I did it this way is because I could not source the .xlsx file and then I couldn't use OLE DB sourcing because I think the .xlsx
file wants you to use Microsoft.ACE.OLEDB.12.0 and that entails installing the 64-bit Microsoft Access Database Engine and I cannot do that because our network version of Microsoft Office 2010 is 32-bit and in order to install the 64-bit Microsoft Access Database
Engine 2010 it's prompting me to uninstall Microsoft Office 2010 and that is not possible.
Ugh!
So I'm hoping that I can promote and deploy this current SSIS Package to Production and create a SQL Server Agent Job that will successfully run this and its dynamic Excel commands.
Do you know of any hurdles with this? Any anomalies...struggles...
Thanks for your review and am hopeful for a reply.
Here's the C# Script...which works perfectly client side...
string StrFileName = (Dts.Variables["User::FileName"].Value.ToString());
StrFileName = Path.GetFileNameWithoutExtension(StrFileName);
string StringSourceFile = (Dts.Variables["User::FilePath"].Value.ToString()) + StrFileName + ".xlsx";
string StringDestinationFile = (Dts.Variables["User::FilePath"].Value.ToString()) + StrFileName + ".xls";
// This initiates the Excel Application
Microsoft.Office.Interop.Excel.Application excelApplication = new Microsoft.Office.Interop.Excel.Application();
// This Opens the Source .xlsx File from Emdeon ePaySmart
Workbook workbook = excelApplication.Workbooks.Open(StringSourceFile, XlUpdateLinks.xlUpdateLinksNever, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// This will Save the Source .xlsx Emdeon ePaySmart File as a .xls File...note xlFileFormat.xlExcel5
workbook.SaveAs(StringDestinationFile, XlFileFormat.xlExcel8, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// This will Close the Source
workbook.Close(false, Type.Missing, Type.Missing);
// This shuts down the Excel Application
excelApplication.Quit();This should work if you use a proxy to run this package in the Agent; see:
http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
Arthur
MyBlog
Twitter -
SQL Server Agent Job intermittently running for packages on SSISDB
I created an SSIS package to pull data from OLAP Cube and push it into SQL Server using SSIS 2o12. I deployed the same on the SQL Server SSIS DB and created a SQL Server Agent Job to run the package. I have an account configured to run the job (not by
creating proxy in the job, but SQL Server Agent is running under that account), that has access to the OLAP Cube. The job is running sometimes and failing sometimes. Why the job behaving weirdly. Any help on the issue will help me a lot. I am using SQL Server
2012 SP1 enterprise edition (11.0.3000.0) (if it helps). The error message which pops up when it fails is :
OLE DB Source failed the pre-execute phase and returned error code 0xC0202009
SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E05.
An OLE DB record is available. Source: ""Microsoft OLE DB Provider for SQL Server 2012 Analysis Services."" Hresult: 0x00000001 Description: ""Error Code = 0x80040E05, External Code = 0x00000000:."".
"Hi,
You are using Execute SQL Task to run a MDX query, right? If so, here is an approach/workaround for your reference. If the MDX query doesn’t have parameters, you can create a view in SQL running the MDX query and make the Execute SQL Task to get data
from that view. If the MDX query has parameters, you can try a Function and create a stored procedure, and then set the Execute SQL Task to execute that stored procedure.
Regards,
Mike Yin
TechNet Community Support -
SSIS package fails under SQL Server Agent job
Hi All
I have designed a SSIS package to encrypt a file using Cipher (EFS) it works fine from BIDS & Package Execution Utility.
But SQL Server Agent job is failing to do this. I am getting the error as
" In executing C:\Windows\System32\Cipher.exe /e /a C:\Test.txt at "",The Process Exit code was 1 while the expected was 0."
Please help me.
ThanksTwo things that usually come to mind when this happens from BIDS locally to the SQL Agent are
1. Security is not
adequate under the SQL Agent Service Account
Rule the security problem out by setting up a proxy account that you know ahs security to run the needed tasks in the package. Either that or give the service account the permissions needed.
2. 32bit BIDS development and running under a 64bit Platform in your SSIS installation
This can be fixed by selecting run in 32bit more or running the package with the 32bit installed version of DTEXEC found in the Program Files (x86) folder where you installed tools.
Next, setup logging in the package so you get a more detailed error message. Event handlers on the tasks will be much more detailed using the OnError event. you can write that to either a flat file with a data flow in the event handler or simply
insert the event into a table using the ? as the parms. If you need assistance setting that up, here are basic steps for a SQL Server table
1) Select the task and click the event handler tab in BIDS
2) Select OnError event handler in the list
3) Click the enable link and drag a Execute TSQL Task over to the window
4) Create a table in your SQL Server database (create one so you don't litter your user DBs if needed)
5) Open the task and add the connection as needed. Then add this statement
INSERT INTO dbo.TableYouCreated
(PackageName, SourceName, EventInfo)
VALUES (?,?,?)
6) Go to parameter mappings and add 4 new mappings as following
System::PackageName
Input
nvarchar
0
System::SourceName
Input
nvarchar
1
System::ErrorDescription
Input
nvarchar
2
Save and reimport the package and then the event of the errors should insert into the table in detail
Ted Krueger
Blog on lessthandot.com @onpnt on twitter -
Error While executing a SSIS package which contains a script task through SQL Server Agent job
Hi,
I have a SQL Server 2012 SSIS package with a script task along with other tasks [data flow, execute sql tasks ]. When I manually executed the job through BIDS, its completed successfully.
Then I have automated the execution of the package through SQL Server Agent Job. But when I executed the package through SQL Agent job, it runs successfully for all the tasks except script task. When it comes to execute the Script Task, it is getting failed
with the below error message.
"Error: 2012-08-29 12:45:14.67
Code: 0x00000001
Source: Script Task
Description: Exception has been thrown by the target of an invocation.
End Error
DTExec: The package execution returned DTSER_FAILURE (1).
Started: 12:45:10 PM
Finished: 12:45:14 PM
Elapsed: 4.353 seconds
I have installed the SSIS on the 64-bit environment and SSIS service is running. Also I tried to run the job through 32 bit [job option] but I am getting the above error in all cases.
Any help will be greatly appreaciated !
Thanks,
Navin
- naveen.reddyHi Arthur,
My script task access the excel files in a network share, refresh them all and save them. When I execute the ETL manually or thru DTEXEC, it is executing successfully. I am facing the issue when I am executing thru SQL Agent Job only. Logging also showing
the same error.
"Error: 2012-08-23 12:45:14.67
Code: 0x00000001
Source: Script Task
Description: Exception has been thrown by the target of an invocation.
End Error
DTExec: The package execution returned DTSER_FAILURE (1).
Started: 12:45:10 PM
Finished: 12:45:14 PM
Elapsed: 4.353 seconds
- naveen.reddy -
HOw to avoid DeadLocks when you schedule a Sql Server Agent Job and calling SSIS packages
Hi All,
I have scheduled 2 packages in in Sql Server Agent jobs .
First job which is having Package 1 executing at 11 AM and where I am inserting the data in the table.
Second job which is having Package 2 executing at 12 AM and where I am updating the data in the table based on the first job inserted records.
When I am executing my first job it taking more time and executing till 12 AM and from 12 AM my job 2 also starting ,so getting deadlocks conflicts because inserting happening from job1 and updating happening from Job 2.
How to avoid deadlocks and fix the issue.
Please Suggest .
Thanks & Regards,
AnandHi Anand,
Here is another solution, you can set the Job 2 not to run based on a schedule, and create another SQL Server Agent Job which starts at 12 AM and run with a specified time interval to execute a SQL statement in which you do the following steps:
1. Get the status information of Job 1 using the statement:
DECLARE @i int;
EXEC @i = msdb.dbo.sp_help_job @job_name = ‘Job Name'
2. If the value of @i is 1 which means the status of job 1 is success and current time is, then start the job 2. So, the statement is as follows:
IF @I = 1
EXEC msdb.dbo.sp_start_job @job_name= ‘Job Name’
Regards,
Mike Yin
TechNet Community Support -
VBScript Runs Correctly From Command Prompt, But Not From SQL Server Agent Job
I'm trying to run this script on my local machine to do some post-batch cleanup and it doesn't run correctly from the scheduled job (or when I invoke the job).
Here's the script in question:
Option Explicit
Const filePath = "C:\Documents and Settings\jmunn\My Documents\Visual Studio 2008\Logs\"
Const holdDays = 6
main
Sub Main()
ClearArchive
End Sub
Sub ClearArchive()
Dim fso 'As Scripting.FileSystemObject
Dim fld 'As Scripting.Folder
Dim f 'As Scripting.File
Dim delLogName, delLogOut, delCtr
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(filePath)
delLogName = filePath & "Nightly Backup - Backup Logs Deleted" & ".txt"
Set delLogOut = fso.CreateTextFile(delLogName, True)
delLogOut.WriteLine(delLogName)
delLogOut.WriteLine("")
delLogOut.WriteLine("-- The following log files were deleted on " & DateValue(Now()) & " at " & TimeValue(Now()))
delLogOut.WriteLine("")
delCtr = 0
For Each f In fld.Files
If Left(f.Name, 48) = "Nightly Backup - SQL Server Databases_Subplan_1_" And Right(LCase(f.Name), 4) = ".txt" Then
If DateDiff("d", f.DateCreated, Date()) > holdDays Then
delLogOut.WriteLine(f.Name)
fso.DeleteFile f, True
delCtr = delCtr + 1
End If
End If
Next
If delCtr = 0 Then
delLogOut.WriteLine("No log files were deleted this run...")
End If
Set fld = Nothing
Set fso = Nothing
delLogOut.Close
End Sub
If I put the script in its own file and run it from the command prompt, it runs just fine. If the script runs from the SQL Server Agent job, the for-loop will delete the files correctly, but the filenames
do not get written to the deletion log file and the counter does not get incremented, so according to the job log, nothing was deleted. Why does the script run differently from each invocation? It can't be a permission thing, the service that logs in has full
access to the directory and the files do get deleted. Any ideas out there?
Between this and other outstanding issues, I'm quickly losing faith in SQL Server. >=o(
Thanks in advance for your thoughts!
John
Version Info:
Microsoft SQL Server Management Studio 10.0.2531.0
Microsoft Analysis Services Client Tools 10.0.1600.22
Microsoft Data Access Components (MDAC) 3.85.1132
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 8.0.6001.18702
Microsoft .NET Framework 2.0.50727.3603
Operating System 5.1.2600
"A bus station is where a bus stops. A train station is where a train stops. On my desk I have a workstation..."Hi
jrmunn
i am trying to execute VB script to refresh my excel files.. using Vbscript file through SQL Agent job step.
i have copied VBscript in a file with the extension RefreshExcel.vbs kept in C:\RefreshExcel.vbs
Below is the script used inside the file (RefreshExcel.vbs)
//---Script code-----------------------------------------------------------------
Dim objXL, objWB
Dim FileLocation, FileName
On Error Resume Next
'lgnConn = 1
FileLocation = "F:\Reports\Reports"
Set objXL = CreateObject("Excel.Application")
objXL.DisplayAlerts = False
FileName = "ReportFile1.xlsx"
'MsgBox (FileLocation & "/" & FileName)
Set objWB = objXL.Workbooks.Open(FileLocation & "/" & FileName)
objWB.EnableConnections
objXL.CalculateUntilAsyncQueriesDone
objWB.RefreshAll
objXL.CalculateUntilAsyncQueriesDone
objWB.RefreshAll
objXL.CalculateUntilAsyncQueriesDone
objWB.Save
objWB.Close
Set objWS = Nothing
Set objWB = Nothing
objXL.Quit
Set objXL = Nothing
'MsgBox ("Refresh Completed")
---------------------------------------------------------------------------------------------------//Script complete
Now when i am trying to call this script file in SQL agent job step (as you mentioned )
as Type -cmdExec(OperatingSystem)
cscript "C:\RefreshExcel.vbs"
Issue: job step executed succesfully ,,but without performing any refresh on the excel. So i am not understandig what is going wrong. the same script file work when i am calling it through a batch file (window scheuler task). But it doesnt support
to run the file "when user is not logged in"
that is why i want to refresh my excel file through sql agent ,which can be scheduled to any time and cab be run as SQL agent credentials.
Can you please help me on this ...i have tried all the option but nothing working .. found hope by seeing your solution.
Thanks in advance.
Please help me. :-(
Maybe you are looking for
-
How do I delete large number of email messages?
I get a large number of emails. Is there a way to select them on my iPod Touch 32g in groups rather than one at a time when I delete many messages?
-
Weird image processor issue in CS4
All of a sudden this week, both of my computers stopped being able to image process via bridge > ps. Repro steps: 1. Select RAW image(s) in Bridge. 2. Tools > Photoshop > Image Processor Expected results: Image processor dialog opens in PS Actual res
-
Project Online - Can't Delete Resource and User from Delete Enterprise Objects
I would like to link a resource account to a user account but I ran into an error: "The resource account is already in use.". This is a known issue which I attempted to resolve by following the instructions in KB2881398. However when deleting the se
-
Best Practices for AD and Windows Environment
Hello Everyone, I need to create a document having the best practices for AD containing best practices for DNS, DHCP, AD Structure, Group Policy, Trust Etc. I just need the best practices irrespective of what is implemented in our company. I just nee
-
Is there a way to charge Ipad 1 while on a long commercial flight? Thanks, RSood