Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathScript-Object.ps1
More file actions
Latest commit
15 lines (14 loc) · 2.27 KB
/
Copy pathScript-Object.ps1
File metadata and controls
15 lines (14 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
param(
[Parameter(Mandatory=$true,HelpMessage='The name of the database object we wish to script')]
[string] $ObjectName,
[string] $Path="$($ObjectName).sql",
[string] $ConnectionString='Data Source=.\sqlexpress2k8R2;Initial Catalog=master;Integrated Security=SSPI;',
[string] $AtlantisSchemaEngineBaseDir='F:\src\Atlantis.SchemaEngine\'# Adjust for your environment
);
Add-Type-Path "$($AtlantisSchemaEngineBaseDir)\Atlantis.SchemaEngine\bin\Debug\Atlantis.SchemaEngine.dll"
$schemaReader= [Atlantis.SchemaEngine.Container.SQLServer.SQLServerSchemaReaderFactory]::GetSpecificSQLServerSchemaReader($ConnectionString, [Atlantis.SchemaEngine.Enumerations.ContainerMode]::Navigation)
$dbObjects=$schemaReader.ReadObjects() |Where-Object { $_.ObjectName,$_.ObjectDesriptiveName,$_.ObjectQualifiedName-contains$ObjectName };
if ($dbObjects-eq$null) {
ThrowNew-Object System.ArgumentException "Object `"$($ObjectName)`" not found.",'-ObjectName';
}
$dbObjects.Script([Atlantis.SchemaEngine.Enumerations.ScriptGenerationType]::Create, (New-Object Atlantis.SchemaEngine.Configuration.GenerationOptions)).Scripts