Databases Reference
In-Depth Information
Figure 13-28
You could use the
Microsoft.SqlServer.Management.Smo.Scripter
class to script the database. The
next example shows you how. The database in this example is called
"MyDBTEST"
(see Figure 13-29).
Chapter 21 discusses scripting of the database, the schema, and database objects in detail.
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') |
Out-Null
$MyScripter
=
New-Object
("Microsoft.SqlServer.Management.Smo.Scripter")
$server
=
New-Object ('Microsoft.SqlServer.Management.Smo.Server')
'PowerServer3\SQL2008'
$MyScripter.Server
=
$server
$MyScripter.Script($server.databases["MyDBTEST"])
Figure 13-29
You can list database objects such as tables, views, and stored procedures using the
Database
property
of the class
Microsoft.SqlServer.Management.Smo.Server
, as shown here (see Figure 13-30 and
Figure 13-31):
Search WWH ::
Custom Search