Thursday, March 29, 2012
Endless looping job!
PS: i suspected it to be that fetch statement causing the havoc ;)
DECLARE
@.TransactionNb varchar(10),
@.EqId varchar(10)
DECLARE TransactionNb_cursor CURSOR
FOR
SELECT TransactionNb, EqId
FROM DetCom
WHERE UpdCode = 'C'
OPEN TransactionNb_cursor
FETCH NEXT FROM TransactionNb_cursor
INTO @.TransactionNb, @.EqId
WHILE @.@.FETCH_STATUS <> -1
BEGIN
-- Vrifier s'il existe une transaction avec le UpdCode = 'C' dans EntCom
IF (SELECT UpdCode
FROM EntCom
WHERE TransactionNb = @.TransactionNb and EqId = @.EqId) = 'C'
BEGIN
CONTINUE
END
ELSE
BEGIN
RAISERROR (50006, 10, 0, @.TransactionNb, @.EqId)
END
FETCH NEXT FROM TransactionNb_cursor
INTO @.TransactionNb, @.EqId
END
CLOSE TransactionNb_cursor
DEALLOCATE TransactionNb_cursorChange the loop terminator to WHILE @.@.FETCH_STATUS = 0
not <> -1
Friday, February 24, 2012
Enable/Disable Job with SMO
I am trying to enable/disable a job using a using smo in a script task with the following code
Imports System.Object
Imports Microsoft.SqlServer.Management.Common
Imports Microsoft.SqlServer.Management.Smo
Imports Microsoft.SqlServer.Management.Smo.Agent
Imports Microsoft.SqlServer.Management.Smo.SqlSmoObject
Imports Microsoft.SqlServer.Management.Smo.SmoObjectBase
Imports Microsoft.SqlServer.Management.Smo.NamedSmoObject
Imports Microsoft.SqlServer.Management.Smo.Agent.Job
Imports Microsoft.SqlServer.Management.Smo.Agent.Jobserver
Imports Microsoft.SqlServer.Management.Smo.Agent.AgentObjectBase
Public Class ScriptMain
Public Sub Main()
Dim strJobserver As JobServer
Dim strJob As Job
Dim srv As Server
srv = New Server("conchango-vpc")
strJob = New Job(srv.JobServer, "test")
strJob.IsEnabled = True
strJob.Alter()
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
and i get an error at the alter point.
when code is changed to using the following line
srv.Jobserver.Alter()
it runs successfully but no change is made to the job.
What am I missing?
Ifaka Enefe
Conchango
Instead of: Use:
strJob = New Job(srv.JobServer, "test")
strJob = srv.JobServer.Jobs("test")
I've got the followinng inside a class library:
Server serv; Job jb; serv = new Server(this.strServerName); jb = serv.JobServer.Jobs(this.strJobName); if (strJobEnabledStatus=="True") { jb.IsEnabled = true; } else { jb.IsEnabled=false; } jb.Alter();
And it complains about
serv.JobServer.Jobs(this.strJobName)
Any ideas? I aint much a developer I'm afraid so I'm at a bit of a loss here.
Thanks
Jamie|||s'all right. I've found it.
jb = serv.JobServer.Jobs[this.strJobName];
Must get my head out of VB mode
-Jamie
Enable/Disable Job with SMO
I am trying to enable/disable a job using a using smo in a script task with the following code
Imports System.Object
Imports Microsoft.SqlServer.Management.Common
Imports Microsoft.SqlServer.Management.Smo
Imports Microsoft.SqlServer.Management.Smo.Agent
Imports Microsoft.SqlServer.Management.Smo.SqlSmoObject
Imports Microsoft.SqlServer.Management.Smo.SmoObjectBase
Imports Microsoft.SqlServer.Management.Smo.NamedSmoObject
Imports Microsoft.SqlServer.Management.Smo.Agent.Job
Imports Microsoft.SqlServer.Management.Smo.Agent.Jobserver
Imports Microsoft.SqlServer.Management.Smo.Agent.AgentObjectBase
Public Class ScriptMain
Public Sub Main()
Dim strJobserver As JobServer
Dim strJob As Job
Dim srv As Server
srv = New Server("conchango-vpc")
strJob = New Job(srv.JobServer, "test")
strJob.IsEnabled = True
strJob.Alter()
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
and i get an error at the alter point.
when code is changed to using the following line
srv.Jobserver.Alter()
it runs successfully but no change is made to the job.
What am I missing?
Ifaka Enefe
Conchango
Instead of: Use:
strJob = New Job(srv.JobServer, "test")
strJob = srv.JobServer.Jobs("test")
I've got the followinng inside a class library:
Server serv; Job jb; serv = new Server(this.strServerName); jb = serv.JobServer.Jobs(this.strJobName); if (strJobEnabledStatus=="True") { jb.IsEnabled = true; } else { jb.IsEnabled=false; } jb.Alter();
And it complains about
serv.JobServer.Jobs(this.strJobName)
Any ideas? I aint much a developer I'm afraid so I'm at a bit of a loss here.
Thanks
Jamie|||s'all right. I've found it.
jb = serv.JobServer.Jobs[this.strJobName];
Must get my head out of VB mode
-Jamie