Click here to Skip to main content
15,850,685 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a database named UB-ReTS1 which contains tables; Document, UserAccount and BackupRestore. Now I need to backup only a part of my database, I only need to backup the table Document and UserAccount. I have the following code which will backup the whole database:

C#
protected void Button2_Click(object sender, EventArgs e)
    {
        string dbname2 = "[UB-ReTS1]";

        string filePath = Server.MapPath(FileUpload1.FileName);

        RestoreDataBase(strPath, dbname2, "Server=.\\SQLEXPRESS;database=" + dbname + ";Integrated Security=True;Pooling=False;");

        ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Database restoration succeeded.');", true);
    }


Please help me and thanks in advanced!!
Posted

1 solution

This question opens up some questions to how your SQL enviroment is set up. As far as I know, SQL does not support the backup of a specific table. It does however support the backup of a specific filegroup, and in turn its associated files. What you will need to do is create a new filegroup on your sql database, and assign the tables you want to specifically back up to that filegroup. Then, you can go through a process of backing up that filegroup, and you will get the files associated to that filegroup (which are your tables).

If you have any questions, let me know in a comment.
 
Share this answer
 
Comments
timJosh 15-Nov-13 12:39pm    
My BackupRestore table contains the database backkup history, what possible solutions I should do in order to not overwrite the info on the history?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900