Skip to content

Instantly share code, notes, and snippets.

@zippy1981
Created February 24, 2011 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zippy1981/843079 to your computer and use it in GitHub Desktop.
Save zippy1981/843079 to your computer and use it in GitHub Desktop.
Experiments with he newly open sourced Atlantis.SchemaEngine.dll
# Adjust these per your environment
[string] $AtlantisSchemaEngineBaseDir = 'F:\src\Atlantis.SchemaEngine\';
[string] $SqlServerInstance = 'localhost\SQLEXPRESS2k8R2';
[string] $dbName = 'master'
# This line works:
Add-Type -Path "$($AtlantisSchemaEngineBaseDir)\Atlantis.SchemaEngine\bin\Debug\Atlantis.SchemaEngine.dll"
[string] $cnStr = "Data Source=$SqlServerInstance;Initial Catalog=$dbName;Integrated Security=SSPI;";
Write-Host "Connection String: $cnStr";
try {
$schemaReader = [Atlantis.SchemaEngine.Container.SQLServer.SQLServerSchemaReaderFactory]::GetSpecificSQLServerSchemaReader($cnStr, [Atlantis.SchemaEngine.Enumerations.ContainerMode]::Comparison)
$dbObjects = $schemaReader.ReadObjects()
Write-Host 'Tables';
$tables = $dbObjects | Where-Object { $_.ObjectSubClass -eq 'Table' }
$tables | Select-Object Name, PlainObjectQualifiedName, ReferencingExecutableObjects;
Write-Host 'Stored Procedures';
$storedProcs = $dbObjects | Where-Object { $_.ObjectSubClass -eq 'StoredProcedure' }
$storedProcs;
}
catch [Exception] {
Write-Host $_.Exception.ToString()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment