I need to provide some data to an organisation (lets call them DataCo) that we're working with. Since we're both SQL server shops, my counterpart at DataCo requested an .mdf file.

However, our database contains many tables that DataCo don't need. Moreover, they're only interested in rows from the last X years. For many reasons (inc. file size) I'd like an .mdf file containing only the data that DataCo need.

Is this possible?

  • If you are ok with sharing data you can export data to excel sheet or csv file and provide them. You can write query to filter out rows you want to provide. Or you can create a new database use import export wizard to move data from old DB to new DB and provide mdf and ldf file to customer
    – Shanky
    Commented Sep 9, 2014 at 11:25

2 Answers 2


With some clever jiggery-pokery with partitioning and filegroups you could get a particular sub-set of your data onto just one of the physical files used by a particular database. Trying to attach that into an existing database at the recipient would be "challengining", I think. In 20-some years of doing this stuff I've not heard of anyone trying that.*

My suggestions would be
a) copy your DB, delete the stuff you don't want to pass on, send a backup of that to the recipient
b) use BCP with the queryout option to dump just the required data to external files. Send those to the recipient.

*I'm always willing to learn, however.


You can try this

Generate a schema script and create a new database using that

  1. Right click the database

  2. Select Tasks -> Generate Scripts(Intro screen-Click next)

  3. Choose "Select specific database objects"

  4. Pick the objects to generate scripts for (tables, stored procedures, etc...)

  5. Click Next, then specify the output filename(on Advance Options(Types of data to script) you can choose data as well by default it is schema only)

  6. Click Finish to generate the script

Use this script to create a dataBase in server

Some script you need to write to copy specific data to this new database

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.