How Can i script the contents of table ?

Hi,
I was wondering if there was a function in SMO to script the entire contents of a table.

What I would like to achieve is to select the table in my App and give an option to script the entire contents of the table including primarykeys constraint etc.


Any suggestions would be very much appreciated.

Thanks


Answer this question

How Can i script the contents of table ?

  • -M-

    Try various scripting options (properties of the ScriptOption class), such as ScriptOption.Default + ScriptOption.DriDefaults + ScriptOption.WithDependencies + ScriptOption.DriPrimaryKey + ScriptOption.DriNonClustered + ScriptOption.DriForeignKeys + ScriptOption.DriUniqueKeys + ScriptOption.SchemaQualify + ScriptOption.DriChecks

    and so on.


  • Joku

    Thanks for the answer.

    I will try now


  • nemesisv

    Sounds about right. Also ensure that PrimaryObject scritping option is selected.

    The reason PrimaryObject exists is that is allows you to script Table Indexes without the table, etc.

  • How Can i script the contents of table ?