Sql-server – Extracting files from partitioned database

partitioningsql server

The company I work for performs services for a couple of hundred customers, all have their own database with identical schemas.

We are planning to merge all of these databases into one, partitioned, database as it will make reporting across all customers easier.

Each table in the database has a customer_id column, so this seems to be the best data item to partition on.

As I understand it, following the merge each partition will have its own mdf and ldf files and these will contain all the data for one customer.

One reason that we have kept the databases separate up to now is that it makes copying a database to our own development environments for debugging or testing new functionality quick as each database is relatively small (100GB typically).

My question is, given that I can get the files for a single customer from the database server is it possible to copy them to my development SQL Server and create a database for that single customer?

Best Answer

As I understand it, following the merge each partition will have its own mdf and ldf files and these will contain all the data for one customer.

...

My question is, given that I can get the files for a single customer from the database server is it possible to copy them to my development SQL Server and create a database for that single customer?

That is wrong. There are no "partitioned databases" in SQL Server, there are partitioned tables and partitioned views. I suppose you tell us about partitioned tables.

Normally, every database has ONLY ONE log file, and even if for some reason some database has more than 1 log file, it has nothing to do with partitioning. So one more time, you misunderstand partitioning.

Partitions are NOT independent databases within your database, you cannot get out one partition by just copying the corrsponding .ndf file. You never can attach a single ndf file, it will never succeed.

And even if you'll try to make partial backup/restore you cannot restore database from one ndf backup without restoring PRIMARY filegroup