1

i want to create script for the table with data,i know, how to generate script of table using c#,but i can't get any coding of script of table with data

 StringCollection tableScripts = myTable.Script(scriptOptionsForDependendencies);
        foreach (string script in tableScripts)
            Console.WriteLine(script);

this ways using

Amit Kumar Singh
  • 4,393
  • 2
  • 9
  • 22
  • what is myTable? – Amit Kumar Singh Sep 13 '17 at 10:46
  • Table myTable = myAdventureWorks.Tables[""]; ScriptingOptions scriptOptionsForDependendencies = new ScriptingOptions(); scriptOptionsForDependendencies.WithDependencies = true; scriptOptionsForDependendencies.DriAll = true; string name = myTable.Name; scriptOptionsForDependendencies.FileName = @"I:\capmanversion\ijob\" + name + ".sql"; StringCollection tableScripts = myTable.Script(); foreach (string script in tableScripts) Console.WriteLine(script);
    – Nithya sudarsan Sep 13 '17 at 10:50

1 Answers1

0

Set scriptOptionsForDependendencies.ScriptData = true. This looks like it will do the work for you.

Put this as scripter.Options.ScriptData = true;

ScriptingOptions sql smo does not support scripting data

Amit Kumar Singh
  • 4,393
  • 2
  • 9
  • 22