Adding stored procedures back up to the existing file
<p>Hi my application does back up of table structure and table data and exports data into a text file . To that existing test file i am trying to export stored procedures backup data as well . I mean i am trying to append this .</p>

<p>Let say if my test file is 120202.txt which has table structure in it and now for stored procedure i am trying to append sproc data as well to the same file the following code :</p>

<pre><code>        if (SPBackupcheck.Checked)
        {
            Server server = new Server(serveName);
            Database db = server.Databases[dbName];
            List&lt;SqlSmoObject&gt; list = new List&lt;SqlSmoObject&gt;();
            DataTable dataTable = db.EnumObjects(DatabaseObjectTypes.StoredProcedure);
            foreach (DataRow row in dataTable.Rows)
            {
                string sSchema = (string)row["Schema"];
                if (sSchema == "sys" || sSchema == "INFORMATION_SCHEMA")
                    continue;
                StoredProcedure sp = (StoredProcedure)server.GetSmoObject(
                    new Urn((string)row["Urn"]));
                if (!sp.IsSystemObject)
                    list.Add(sp);
            }
            Scripter scripter = new Scripter();
            scripter.Server = server;
            scripter.Options.IncludeHeaders = true;
            scripter.Options.SchemaQualify = true;
            scripter.Options.ToFileOnly = true;
            scripter.Options.FileName = **fileToWrite;** // this is the file i am trying to append . How can i achieve this ?
        }
</code></pre>
