X hits on this document

PDF document

The “SQL Server Management Objects” series - page 5 / 6

23 views

0 shares

0 downloads

0 comments

5 / 6

www.tobuku.com

The “SQL Server Management Objects” series

string objType = item.SubItems[1].

Text;

int i = itemName.IndexOf(".", 0); string objName = itemName.Substrin

g(i + 1, itemName.Length - i -

1); string objSchema = itemName.Substr

ing(0, i);

StringCollection sc=null; string s1 = "";

//generate the SQL script switch(objType) { case "Stored Procedure": Microsoft.SqlServer.Manageme database.StoredProcedures sc = sp.Script(); break; case "Function": Microsoft.SqlServer.Manageme database.UserDefinedFunct sc = fn.Script(); break; case "View": Microsoft.SqlServer.Manageme database.Views[objName, o sc = vw.Script(); break; default: //Trigger string objParent = item.SubI Microsoft.SqlServer.Manageme database.Tables[objParent Microsoft.SqlServer.Manageme tbl.Triggers[objName]; sc = tr.Script(); break;

nt.Smo.StoredProcedure sp = [objName, objSchema];

nt.Smo.UserDefinedFunction fn = ions[objName, objSchema];

nt.Smo.View vw = bjSchema];

tems[2].Text; nt.Smo.Table tbl = , objSchema]; nt.Smo.Trigger tr =

}

foreach (string s in sc) {

s1 += s + Environment.NewLine; }

//write the script to the SQL file try {

TextWriter tw = new StreamWriter(fileName); tw.WriteLine(s1); tw.Close();

MessageBox.Show("File " + fileName + " is successfully writen.", "SQL Script", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message);

  • -

    5-

Document info
Document views23
Page views23
Page last viewedThu Dec 08 15:11:58 UTC 2016
Pages6
Paragraphs110
Words1400

Comments