Obtain object definition
Brian Donahue
Posts: 6,590 Bronze 1
Hi Steve,
Thanks for your question. You can access an object's creation SQL
through the Region class. Rather than re-invent the wheel, I'll paste a bit
of the Toolkit help file:
Remarks
The script for a SQL object is returned as a collection of regions. For
example, the SQL script for a table might contain regions for columns,
constraints and indexes, foreign keys and permissions
Use ToString to view all the SQL
Example
Viewing the SQL script needed to create a table
[C#]
Database db=new Database();
db.Register(new ConnectionProperties(".", "WidgetStaging"),
Options.Default);
Work work=new Work();
//get the script for an object
Regions regions=work.ScriptObject(db.Tables[0], Options.Default);
Console.WriteLine("Entire SQL script:
{0}", regions.ToString());
Console.WriteLine("By region:
");
foreach (Region region in regions)
{
Console.WriteLine("***{0}", region.Name);
Console.WriteLine(region.SQL);
}
db.Dispose();
[Visual Basic]
Dim db As New Database()
db.Register(New ConnectionProperties(".", "WidgetStaging"), Options.Default)
Dim work As New Work()
'get the script for an object
Dim regions As Regions = work.ScriptObject(db.Tables(0), Options.Default)
Console.WriteLine("Entire SQL script:")
Console.WriteLine("{0}", regions.ToString())
Dim region As Region
For Each region In regions
Console.WriteLine("***{0}", region.Name)
Console.WriteLine(region.SQL)
Next
'dispose
db.Dispose()
"Steve P" <stp5345@yahoo.com> wrote in message
news:VWgce9y9DHA.2768@server53...
> Is there a way to capture the object definitions that are compared?
> For example, have access to Table1's "CREATE TABLE ..." script for each
> database that is compared..
>
>
Thanks for your question. You can access an object's creation SQL
through the Region class. Rather than re-invent the wheel, I'll paste a bit
of the Toolkit help file:
Remarks
The script for a SQL object is returned as a collection of regions. For
example, the SQL script for a table might contain regions for columns,
constraints and indexes, foreign keys and permissions
Use ToString to view all the SQL
Example
Viewing the SQL script needed to create a table
[C#]
Database db=new Database();
db.Register(new ConnectionProperties(".", "WidgetStaging"),
Options.Default);
Work work=new Work();
//get the script for an object
Regions regions=work.ScriptObject(db.Tables[0], Options.Default);
Console.WriteLine("Entire SQL script:
{0}", regions.ToString());
Console.WriteLine("By region:
");
foreach (Region region in regions)
{
Console.WriteLine("***{0}", region.Name);
Console.WriteLine(region.SQL);
}
db.Dispose();
[Visual Basic]
Dim db As New Database()
db.Register(New ConnectionProperties(".", "WidgetStaging"), Options.Default)
Dim work As New Work()
'get the script for an object
Dim regions As Regions = work.ScriptObject(db.Tables(0), Options.Default)
Console.WriteLine("Entire SQL script:")
Console.WriteLine("{0}", regions.ToString())
Dim region As Region
For Each region In regions
Console.WriteLine("***{0}", region.Name)
Console.WriteLine(region.SQL)
Next
'dispose
db.Dispose()
"Steve P" <stp5345@yahoo.com> wrote in message
news:VWgce9y9DHA.2768@server53...
> Is there a way to capture the object definitions that are compared?
> For example, have access to Table1's "CREATE TABLE ..." script for each
> database that is compared..
>
>
This discussion has been closed.