Using SMO to script PARTIAL data content (only rows matching a WHERE clause)
I use SMO to fill a SQL Compact database with the data of a SQL server database. Here is the code I actually use: foreach(Table l_tblCurrent in l_dbDatabase.Tables) { if(l_tblCurrent.IsSystemObject) continue; ScriptingOptions l_scOptions = new ScriptingOptions(); l_scOptions.NoIdentities = true; l_scOptions.NoCollation = true; l_scOptions.NoCommandTerminator = true; l_scOptions.NoFileGroup = true; l_scOptions.ScriptSchema = true; l_scOptions.ScriptData = true; foreach(string l_strCurrent in l_tblCurrent.EnumScript(l_scOptions)) { l_sccDBFCommand.CommandText = l_strCurrent.Replace("[dbo].", "")