Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6571517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:53:34+00:00 2026-05-25T14:53:34+00:00

I need to backup database (using SQL Server 2008 R2). Size of db is

  • 0

I need to backup database (using SQL Server 2008 R2). Size of db is about 100 GB so I want backup content only of important tables (containing settings) and of course object of all tables, views, triggers etc.

For example:

  • db: Products
  • tables: Food, Clothes, Cars

There is too much cars in Cars, so I will only backup table definition (CREATE TABLE ...) and complete Food and Clothes (including its content).

Advise me the best solution, please. I will probably use SMO (if no better solution). Should I use Backup class? Or Scripter class? Or another (if there is any)? Which class can handle my requirements?

I want backup these files to *.sql files, one per table if possible.

I would appreciate code sample. Written in answer or somewhere (post url), but be sure that external article has solution exactly for this kind of problem.

You can use this part of code

ServerConnection connection = new ServerConnection("SERVER,1234", "User", "User1234");
Server server = new Server(connection);
Database database = server.Databases["DbToBackup"];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:53:35+00:00Added an answer on May 25, 2026 at 2:53 pm

    This arcitle was enough informative to solve my problem. Here is my working solution.
    I decided script all objects to one file, it’s better solution because of dependencies, I think. If there is one table per on file and there is also some dependencies (foreign keys for example) it would script more code than if everything is in one file.

    I omitted some parts of code in this sample, like backuping backup files in case wrong database backup. If there is no such a system, all backups will script to one file and it will go messy

    public class DatabaseBackup
    {
        private ServerConnection Connection;
        private Server Server;
        private Database Database;
        private ScriptingOptions Options;
        private string FileName;
        private const string NoDataScript = "Cars";
    
        public DatabaseBackup(string server, string login, string password, string database)
        {
            Connection = new ServerConnection(server, login, password);
            Server = new Server(Connection);
            Database = Server.Databases[database];
        }
    
        public void Backup(string fileName)
        {
            FileName = fileName;
            SetupOptions();
    
            foreach (Table table in Database.Tables)
            {
                 if (!table.IsSystemObject)
                 {
                      if (NoDataScript.Contains(table.Name))
                      {
                           Options.ScriptData = false;
                           table.EnumScript(Options);
                           Options.ScriptData = true;
                      }
                      else
                           table.EnumScript(Options);
                  }
             }
        }
    
        private void SetupOptions()
        {
             Options = new ScriptingOptions();
             Options.ScriptSchema = true;
             Options.ScriptData = true;
             Options.ScriptDrops = false;
             Options.WithDependencies = true;
             Options.Indexes = true;
             Options.FileName = FileName;
             Options.EnforceScriptingOptions = true;
             Options.IncludeHeaders = true;
             Options.AppendToFile = true;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a backup of a SQL Server 2005 Database that's only
When I backup or restore a database using MS SQL Server Management Studio, I
I'm using SQL Server 2005. I need to move a database to a new
Whenever I restore a backup of my database in SQL Server I am presented
I have a synchronous mirroring environment with automatic fail-over using sql server 2008 standard
I am using mysqldump to backup mysql database. Now I just need to use
I'm looking for a way to create a backup of a SQL Server 2008
I need to be able to backup and restore my database using tsql. The
I have a SQL 2008 job that does database backups using a Powershell script.
Hi I need to backup MySQL database and then deploy it on another MySQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.