My application has a database that I create from a backup file in this way:
-- create empty db
CREATE DATABASE MyNewDB
-- restore on the empty db from file
RESTORE DATABASE MyNewDB
FROM DISK = 'c:\Temp\MyNewDB.bak'
WITH REPLACE,
MOVE 'MyDB_Data' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.EXPRESS2008R2\MSSQL\DATA\MyNewDB.mdf',
MOVE 'MyDB_Log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.EXPRESS2008R2\MSSQL\DATA\MyNewDB_log.LDF',
MOVE 'MyDBFS' TO 'C:\FileStreamData\MyNewDBFS'
I use the filestream filegroup to store the blobs only, basically I have a single table where I store files there and a single blob column containing the binary data that is saved as SQL Server Filestream data.
As customers keep using the app the filestream part becomes huge, it can be that mdf is 500MB and filestream is 60GB
Often to debug an issue on the development machine I need to transfer "only the tables" ("500MB") and "not the blobs" ("60GB").
What I do is duplicating the database and on the duplicated database, I set the blob column to NULL in the files table and then I run
CHCEKPOINT
I then wait for the garbage collector to finish its job and then I can take a backup and have a small file.
Sometimes I do not have space to restore a copy of the backup or I do not have time to do it.
So what I'd love to be able to do, but I did not find a solution in all the web is:
Copy the
.mdf
+.ldf
only (that contain the data)Somehow create "fake filestream data" (data that SQL Server will accept on attach)
Attach
.mdf
,.ldf
and fake filestream data to create a test database
Of course, I do not expect the queries on the blobs to work, but all the queries on the other tables, yes.
Is there a way (may be even using a 3d party tool) to achieve what I need?