Description
openedon May 27, 2020
Hi, am trying to write some powershell to script out sql server objects - my code is as below
$scriptr = new-object ('Microsoft.SqlServer.Management.Smo.Scripter') ($SMOserver)
foreach ($ScriptThis in
$scriptr = new-object ('Microsoft.SqlServer.Management.Smo.Scripter') ($SMOserver)
$scriptr.Options.AppendToFile = $False
$scriptr.Options.ScriptSchema = $True
$scriptr.Options.AllowSystemObjects = $False
$scriptr.Options.ClusteredIndexes = $True
$scriptr.Options.DriAllConstraints = $True
$scriptr.Options.ScriptDrops = $False
$scriptr.Options.IncludeIfNotExists = $False
$scriptr.Options.IncludeHeaders = $False
$scriptr.Options.ToFileOnly = $True
$scriptr.Options.Indexes = $True
$scriptr.Options.Permissions = $False
$scriptr.Options.WithDependencies = $False
$scriptr.Options.IncludeDatabaseContext = $True
$scriptr.Options.Triggers = $True
$scriptr.Options.EnforceScriptingOptions = $True....
How do I specify 'create or alter' here? If I say $scriptr.Options.CreateorAlter = $true i get an error. I have to do all sorts of manipulations to change generated script to use create or alter, thanks.