Well, to accomplish this you need to have 3 or 4 Filegroups in SQL Server:
1) PRIMARY (Standard); contains system objects
2) Filegroup Company A; to store all tables from company A
3) Filegroup Company B; to store all tables from company B
4) Filegroup Common; to store all tables which are common for all companies
Then you could move all tables into the specific filegreoups:
- DROP all Non-Clustered-Indexes (NCI)
- DROP Clustered-Index using MOVE TO clause to transfer the data into the new filegroup
- CREATE Clustered-Index in new filegroup
- CREATE all Non-Clustered-Index in new filegroup
(of course there's NO chance to do this with NAV - you need to createTSQL scripts)
Then you could use the BACKUP DATABASE command using the FILEGROUP specification; hence you could backup just a single company. But to grant data integrity, you always have to save multiple FG; for example:
PRIMARY + COMPANY_A + COMMON
or
PRIMARY + COMPANY_B + COMMON
Then be aware, that whenever you change/save a table in "Object Designer" indexes could be reset to the default FG.
So, YES - technically it is possible to save just one company, but this requires a LOT of effort and SQL programming.
I'd say it's easier to use the native NAV backup ... :-k
Didn't Rashed (ara3n) create a program to do this and then shared it on Mibuso? I am pretty sure I saw something, but not sure if in downloads or blogs or tips and tricks.
Ah! Haven't seen this before! Nice! =D>
So you just copy the data into a new database. But this could also mean a huge workload on large databases. Also, you have to repeat this process completely from the scratch with ever Company Backup you want to create.
IMHO for a "one shot" solution this is great (e.g. for setting up a Test-DB or something), for a permanent solution I guess this is not really feasible ... especially, as you CANNOT restore such a backup into the real live database.
as you CANNOT restore such a backup into the real live database.
Why not? You could just copy it back...
True. But I do not consider this as a normal SQL Backup/Restore proceeding.
If you need to restore, you need to 1) restore the "One_Company_DB" from the SQL BAK, then transfer the data back into the real DB.
Again, for a small database this might be OK, but for a large system I'd say this is way too much effort ...
Comments
1) PRIMARY (Standard); contains system objects
2) Filegroup Company A; to store all tables from company A
3) Filegroup Company B; to store all tables from company B
4) Filegroup Common; to store all tables which are common for all companies
Then you could move all tables into the specific filegreoups:
- DROP all Non-Clustered-Indexes (NCI)
- DROP Clustered-Index using MOVE TO clause to transfer the data into the new filegroup
- CREATE Clustered-Index in new filegroup
- CREATE all Non-Clustered-Index in new filegroup
(of course there's NO chance to do this with NAV - you need to createTSQL scripts)
Then you could use the BACKUP DATABASE command using the FILEGROUP specification; hence you could backup just a single company. But to grant data integrity, you always have to save multiple FG; for example:
PRIMARY + COMPANY_A + COMMON
or
PRIMARY + COMPANY_B + COMMON
Then be aware, that whenever you change/save a table in "Object Designer" indexes could be reset to the default FG.
So, YES - technically it is possible to save just one company, but this requires a LOT of effort and SQL programming.
I'd say it's easier to use the native NAV backup ... :-k
Last but not least: why do you want to do this?
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
So you just copy the data into a new database. But this could also mean a huge workload on large databases. Also, you have to repeat this process completely from the scratch with ever Company Backup you want to create.
IMHO for a "one shot" solution this is great (e.g. for setting up a Test-DB or something), for a permanent solution I guess this is not really feasible ... especially, as you CANNOT restore such a backup into the real live database.
So again, it depends on the purpose ...
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
Peter
If you need to restore, you need to 1) restore the "One_Company_DB" from the SQL BAK, then transfer the data back into the real DB.
Again, for a small database this might be OK, but for a large system I'd say this is way too much effort ...
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool