Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 copying database for one month's data only

Author  Topic 

thisisboni
Starting Member

6 Posts

Posted - 2009-07-26 : 11:15:31
Hi:

We are running SQL Servre 2005 -
I want to copy only one month's data onto my local laptop for training - how best can I do this ?

Thanks

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-07-26 : 11:43:14
Let ssms create a script to create a new database like your source database.
Insert the data you want via insert command.
backup the new database.
Take the backup file to your laptop and make a restore.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

thisisboni
Starting Member

6 Posts

Posted - 2009-07-26 : 12:11:41
Thanks I created a new dB like the source

Now the source dB has 15Gb of data - I just need a portion of the data - (say a month's of data) -

for the Dim tables I need all rows but fact tables I need only a month's worth of data - how would I do this

I am connected to the source via vpn and RDP

and the destination is in my local

Thanks
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-07-26 : 13:27:30
the new db is to create on the source-server.
Then you have:
source tables with data and destination with empty tables.
I cannot see your system so there may be some traps like identity columns etc.

But in generally you have to the following for all needed tables:
insert new_db..dim_table (col1, col2, col3) select col1,col2,col3 from source_db..dim_table
insert new_db..fact_table (col1, col2, col3) select col1,col2,col3 from source_db..fact_table where datecol >= '20090501' and datecol < '20090601'

The result is a database with less data than the source db.
Now make a backup from the new_db and copy the backup file to your laptop.
In ssms on your laptop you can restore the backup.

Ready.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -