开发者

Backup and Restore Filtered Data from SQL Server database using C#

开发者 https://www.devze.com 2022-12-14 17:32 出处:网络
I wish to implement backup and restore feature for my application. Here I want to backup filte开发者_开发百科red data(not the whole database).

I wish to implement backup and restore feature for my application. Here I want to backup filte开发者_开发百科red data(not the whole database).

Like Select * from Sales where CompanyId=1 For all tables in database and write these data to a file.bak file, later which I can be used for restore purpose.

My Question here is Is there any way to implement this feature using SMO? If you have any other suggestion about how to implement this, I am very happy to hear it.

Please help me friends..


There is no native way in which you are going to achieve this backup, but there are some awkward workarounds you can do to try to get this functionality.

If every table includes the CompanyId field, you could create a partition schema / function based on the company Id, and specifically place each partition of the schema on to a separate file group. This has then split the data for each CompanyId onto a different file group, which is the key since there is the functionality to perform a file / file group level backup in SQL instead of the entire database.

I wouldn't do this unless it was the last option, I think I would work out exactly what the backup / restore requirements are, and check whether there are better options / choices.

0

精彩评论

暂无评论...
验证码 换一张
取 消