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

[322 byte] By [vbjunkie] at [2008-1-23]
# 1

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.

DarshanSingh at 2007-9-9 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...
# 2
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.

MichielWories at 2007-9-9 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...
# 3
Thanks for the answer.

I will try now

vbjunkie at 2007-9-9 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...

SQL Server

Site Classified