title: SMO - How to script an object in a Dynamic SQL style? (IF NOT EXISTS)
body: <p>When I use SMO to script a procedure with the IncludeIfNotExists set to true, it first creates the procedure and then alters it. Is there a way for it to just create the procedure in a dynamic SQL style? (like in SSMS)</p>
  
  <p>This is what I get from the SMO:</p>
  
  <pre><code>IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[proc_a]') AND type in (N'P', N'PC'))
  BEGIN
  EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[proc_a] AS' 
  END
  GO
  ALTER PROCEDURE [dbo].[proc_a] 
  AS
  BEGIN 
  -- etc..
  END
  GO
  </code></pre>
  
  <p>I want something like this instead:</p>
  
  <pre><code>IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[proc_a]') AND type in (N'P', N'PC'))
  BEGIN
  EXEC dbo.sp_executesql @statement = N'
  CREATE PROCEDURE [dbo].[proc_a] 
  AS
  BEGIN
  -- etc..
  
  END
  ' 
  END
  GO
  </code></pre>