﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Programming / SMO/RMO/DMO  / how to use SQLDMO_SCRIPT_TYPE options in code / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 02:04:12 GMT</lastBuildDate><ttl>20</ttl><item><title>how to use SQLDMO_SCRIPT_TYPE options in code</title><link>http://www.sqlservercentral.com/Forums/Topic910463-22-1.aspx</link><description>Hi,I have the following code that scripts out all agent jobs on a server.  I want the generated script to include If not exists condition coz i either want to skip or overwrite existing jobs.Dim ArgObjDim xDim ServerNameSet ArgObj=Wscript.Argumentsx=ArgObj.Item(0)ServerName=Mid(x,3)Wscript.Echo(ServerName)Dim oSQLServer Dim oStream Set oSQlServer = CreateObject("SQLDMO.SQLServer") Set oStream = CreateObject("ADODB.Stream") oSQLServer.LoginSecure=TrueoSQLServer.Connect ServerNameDim idStep Dim ScriptJob Dim CountJobs Dim JobName Dim ScriptAllJobsFor Each oJob In oSQLServer.JobServer.Jobs       JobName = oJob.Name     if (InStr(UCase(JobName), "MIRRORING") &amp;gt; 0) Then     Wscript.Echo("Skipping Job"&amp;JobName)    else    ScriptJob = Replace(oJob.Script(4,"C:\"&amp; JobName &amp;".sql") , ServerName, "(local)")    ScriptAllJobs = ScriptAllJobs &amp; ScriptJob         End If NextoStream.Open oStream.WriteText (ScriptAllJobs) oStream.SaveToFile ("C:\SQLAllScripts.sql"), 2oStream.Close oSQLServer.DisConnectSet oStream = Nothing Set oSQLServer = Nothing Set ArgObj=NothingWhere and how do i implement in this code?</description><pubDate>Mon, 26 Apr 2010 09:12:35 GMT</pubDate><dc:creator>coolchaitu</dc:creator></item></channel></rss>