Skip to content

Unable to use CreateorAlter  #11

Closed

Description

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 $DatabaseObjects | Where-Object { $.schema -eq $schemaname -and -not $.IsSystemObject}) {
$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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions