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

2
  • what is myTable? Commented Sep 13, 2017 at 10:46
  • Table myTable = myAdventureWorks.Tables["<table name>"]; 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); Commented Sep 13, 2017 at 10:50

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

i check this thing but showing error This method does not support scripting data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.