?? ??? ????? ????? ?? ???????? ????? ???? ?? ?????? ?? ????? ??? ?????? ??? ?????? ???? SMO ???????? ????? ????? ???????? ?? SQL Server 2005

?????? ????????? ?????? ?????????
???? ???????: 918480 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???: 403696 (SQLBUDT)
????? ???? | ?? ????

?? ??? ??????

???????

????? ?? ??? ????? ?????? ???? ???? ????? ???? SQL (SMO) ???? ????? ????? ??? ?????? ?? Microsoft SQL Server 2005 ? ????? ?? ???????? ????? ???? ?????? ???????? ???? ??? ??????? ??? ????? ????? ????????. ????? ?? ????? ????? ???????? ????? ???? ?? ?????? ?????? ???????? ???? ????? ???? ?????? ???????? ??? ????? ????? ????? ?????.

???? ??????

?????? ??? ??? ???????, ?????? ???? ????? ???????? ???????? ??? ????? ??? SMO ???? ????? ??? ????? ??? ??????.

??????? ??????? Script ?????? SMO

  1. ????? ???? ScriptingOptions.
  2. ????? ???? ????? ????? ?????? ScriptingOptions ??? True.
  3. ????? ?? ??????? ??????? Script ?????? SMO ? ??????? ??????? Script(ScriptingOptions) ?????? SMO. ?????? ????? ????? ?????? ScriptingOptions ??? ????? ???????? ?????.
??? ???? ??????? ?????? ????????? ???????? ???? ?????? ????????? ???????? ???????.

Microsoft Visual C#

Server srv = new Server(@".\MySQLServer");
Database db = srv.Databases["MyDB"];
View vw = db.Views["MyView"];

//Define the ScriptingOptions object.
ScriptingOptions sco = new ScriptingOptions();

//Set the value of the Indexes property.
sco.Indexes = true;

//Specify the values of the other members of the sco object.

System.Collections.Specialized.StringCollection script = null;

//Pass the ScriptingOptions object.
script = vw.Script(sco);

foreach (string str in script)
{
    Console.WriteLine(str);
    Console.WriteLine("go");
}

Microsoft Visual Basic .NET

Dim srv As Server = New Server(".\MySQLServer")
Dim db As Database = srv.Databases("MyDB")
Dim vw As View = db.Views("MyView")

'Define the ScriptingOptions object.
Dim sco As ScriptingOptions = New ScriptingOptions()

'Set the value of the Indexes property.
sco.Indexes = True

'Specify the values of the other members of the sco object.

'Pass the ScriptingOptions object.
Dim script As System.Collections.Specialized.StringCollection = vw.Script(sco)

Dim str As String
For Each str In script
    Console.WriteLine(str)
    Console.WriteLine("go")
Next str

??????? ?????? Scripter

  1. ????? ???? ??? Options.Indexes ?????? Scripter ??? True.
  2. ?????? ???????? ????? ????? ???? ?????? SMO ??? ??????? Script ?????? Scripter.
??? ???? ??????? ?????? ????????? ???????? ???? ?????? ????????? ???????? ???????.

Visual C#

Server srv = new Server(@".\MySQLServer");
Database db = srv.Databases["MyDB"];
View vw = db.Views["MyView"];

Scripter scr = new Scripter();
scr.Server = srv;

//Set the value of the Options.Indexes member.
scr.Options.Indexes = true;

//Specify the value of the other members of the scr.Options property.

SqlSmoObject[] objs = new SqlSmoObject[1];
objs[0] = vw;

System.Collections.Specialized.StringCollection script = null;

//Pass the SMO object reference to the Script method.
script = scr.Script(objs);

foreach (string str in script)
{
    Console.WriteLine(str);
    Console.WriteLine("go");
}

Visual Basic .NET

Dim srv As Server = New Server(".\MySQLServer")
Dim db As Database = srv.Databases("MyDB")
Dim vw As View = db.Views("MyView")

Dim scr As Scripter = New Scripter()
scr.Server = srv

'Set the value of the Options.Indexes member.
scr.Options.Indexes = True

'Specify the value of the other members of the scr.Options object.

Dim objs As SqlSmoObject() = New SqlSmoObject() {vw}

'Pass the ScriptingOptions object.
Dim script As System.Collections.Specialized.StringCollection = scr.Script(objs)

Dim str As String
For Each str In script
    Console.WriteLine(str)
    Console.WriteLine("go")
Next str
?????? ??????? ?????? ?????? Scripter ?????? ???? ScriptingOptions.

??????? ???? ?????

  1. ????? ???? ??? Options.Indexes ???? ????? ??? true.
  2. ?????? ???????? ????? ??????? ????? ScriptTransfer ???? ?????.
??? ???? ??????? ?????? ????????? ???????? ???? ?????? ????????? ???????? ???????.

Visual C#

Server srv = new Server(@".\MySQLServer");
Database db = srv.Databases["MyDB"];

Transfer trans = new Transfer(db);

//Set the value of the Options.Indexes member.
trans.Options.Indexes = true;

//Specify the value of the other members of the trans.Options property.

System.Collections.Specialized.StringCollection script = null;

//Use the ScriptTransfer method of the Transfer object to generate the script.
script = trans.ScriptTransfer();

foreach (string str in script)
{
    Console.WriteLine(str);
    Console.WriteLine("go");
}

Visual Basic .NET

Dim srv As Server = New Server(".\MySQLServer")
Dim db As Database = srv.Databases("MyDB")

Dim trans As Transfer = New Transfer(db)

'Set the value of the Options.Indexes member.
trans.Options.Indexes = True

'Specify the value of the other members of the trans.Options property.

'Use the ScriptTransfer method of the Transfer object to generate the script.
Dim script As System.Collections.Specialized.StringCollection = trans.ScriptTransfer()

Dim str As String
For Each str In script
    Console.WriteLine(str)
    Console.WriteLine("go")
Next str
?????? ??????? "??????" ?????? ????? ?????? ???? ScriptingOptions.

?????

???? Microsoft ?? ??? ????? ?? ?????? Microsoft ??????? ?? ??? "????? ???".

?????

????? ?? ????????? ??? ??? ScriptingOptions ?? ?????? ???? ???? ????? Microsoft (MSDN) ?????? ??? ?????:
http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.scriptingoptions.aspx

???????

???? ???????: 918480 - ????? ??? ??????: 19/???? ??????/1427 - ??????: 1.1
????? ???
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Workgroup Edition
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Enterprise Edition
????? ??????: 
kbmt kbexpertiseadvanced kbtshoot kbprb KB918480 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????918480

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com