I am working on a project with multi users who can store their individual data. I am confused on how to proceed if a user wants to save his own data from multiple tables as a backup and retrieve it any time if the data is lost or corrupted if anyone has any clue on how to do that would be a great help.
1 Answer
You cannot backup specific tables to a .bak file, but you can export them to a CSV or script them out. What you can do if you want to back up specific tables is move them into a separate file group and back up that file group.
See Back Up Files and Filegroups for the documentation.
Below is an example.
--Back up the files in SalesGroup1.
BACKUP DATABASE Sales
FILEGROUP = 'SalesGroup1',
FILEGROUP = 'SalesGroup2'
TO DISK = 'C:\MySQLServer\Backups\Sales\SalesFiles.bak';
GO