Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Strange error, cannot script out jobs from SQL. Expand / Collapse
Author
Message
Posted Thursday, February 28, 2013 12:01 PM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Wednesday, August 13, 2014 2:54 PM
Points: 611, Visits: 507
When trying to script out a current job on our MSX sql server, we receive this error,"Unable cast object of type 'system.dbnull' to type 'system.string'. (microsoft.sqlserver.smo)"

I cannot find a lot of information on this topic. what would allow this job to run, yet prevent it from being scripted out and moved to our other MSX server?

It will work on some jobs, just not most of them. I do have SA on the box.


===================================

Script failed for Server '*******'. (Microsoft.SqlServer.Smo)

------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.2500.0+((KJ_PCU_Main).110617-0026+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Script+Server&LinkId=20476

------------------------------
Program Location:

at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(DependencyCollection depList, SqlSmoObject[] objects)
at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(Urn[] urns, SqlSmoObject[] objects)
at Microsoft.SqlServer.Management.Smo.Scripter.Script(Urn[] urns, SqlSmoObject[] objects)
at Microsoft.SqlServer.Management.Smo.Scripter.EnumScript(Urn[] urns)
at Microsoft.SqlServer.Management.Smo.Scripter.Script(Urn[] urns)
at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ScriptGenerator.ScriptCreate(SqlTextWriter sqlwriter, Server server, Urn[] urns, SqlScriptOptions options)
at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ScriptNodeActionContext.Script(SqlTextWriter writer)
at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.SqlScriptMenu.OnScriptItemClick(Object sender, EventArgs e)

===================================

Unable to cast object of type 'System.DBNull' to type 'System.String'. (Microsoft.SqlServer.Smo)

------------------------------
Program Location:

at Microsoft.SqlServer.Management.Smo.Agent.Job.GetJobScriptingScript(StringBuilder createQuery, ScriptingOptions so)
at Microsoft.SqlServer.Management.Smo.Agent.Job.ScriptCreate(StringCollection queries, ScriptingOptions so)
at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithListWorker(DependencyCollection depList, SqlSmoObject[] objects)
at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(DependencyCollection depList, SqlSmoObject[] objects)


.
Post #1425236
Posted Thursday, February 28, 2013 7:16 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 2:34 PM
Points: 2,827, Visits: 8,470
Maybe a version mis-match between Management Studio and the installed version of SQL ?


Post #1425326
Posted Thursday, February 28, 2013 10:36 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:38 PM
Points: 7,097, Visits: 12,598
Check the owner of the job(s) in querstion. It may be owned by an SID that does not resolve to a valid login which could be giving SMO heartburn.

SELECT SUSER_SNAME(owner_sid)
FROM msdb.dbo.sysjobs
WHERE name = N'problem_job_name';


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1425348
Posted Friday, March 1, 2013 8:48 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Wednesday, August 13, 2014 2:54 PM
Points: 611, Visits: 507
I tried that just now, it resolves to a good name. I wonder why it states system.dbnull I cannot figure that one out.

These are Multiserver jobs. Though, even when targeted to the current server... it fails to script out.


.
Post #1425558
Posted Friday, March 1, 2013 10:04 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:38 PM
Points: 7,097, Visits: 12,598
Sounds like a bug in SMO.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1425613
Posted Friday, March 1, 2013 10:35 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Wednesday, August 13, 2014 2:54 PM
Points: 611, Visits: 507
opc.three (3/1/2013)
Sounds like a bug in SMO.


I agree. ^.^ I'm trying to track it down and fix it hopefully.


.
Post #1425626
Posted Friday, March 1, 2013 3:57 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: 2 days ago @ 10:29 AM
Points: 272, Visits: 848
In addition to job owner, the "run as" of a step may be associated with an invalid SID.
Post #1425781
Posted Thursday, May 15, 2014 2:32 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, August 18, 2014 10:28 AM
Points: 362, Visits: 576
I had also had this issue today on a test server (e.g., desktop). I've been defecting and re-mastering a lot. I changed my service account today as well - using my first MSA. Someplace one of my jobs (1 of about 60) got stuck as neither completely master or completely local. I could not save changes to it. I could not script it out - got the same error as you did.

I updated the system table for the job to remove the multi-server category. (In the past, I hacked a target job for fun to change it to a local job. I knew what to look for.)

update msdb.dbo.sysjobs
set category_id = 3
where name = 'MyJobNameWithTheIssue'

It was not enough because it had a related sysjobservers record with a non-zero server_id.

DELETE FROM js
FROM msdb.dbo.sysjobservers js
INNER JOIN msdb.dbo.sysjobs j
ON js.job_id = j.job_id
WHERE j.name = 'MyJobNameWithTheIssue'

This was enough. It became a local job that I could edit and script out. (I am very glad I did not have to cut and paste each step.)

PS There is a bug that will not let you remove the default instance as a target from a named instance master on the same machine. (I submitted a bug for this recently. The code is trying to insure that a target is not the master before deleting the job. Good thing to do after a host rename, but it fails to account for named instances.) I had to put the master on the default for testing. Perhaps the issue with this job is related to the bug.


Randy
"Perhaps I'm not the only one that does not know what you are doing."
Post #1571530
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse