Why does smo.transferdata is so long to complete.

Hi,
I want to to create copy of a specific databases using smo object.  I found many examples of code explaining how to do it with transferdata method, but it is extremly slow.  The database is around 200 MB and itt take 20 minutes to complete on a dual core with 2 gig of ram.  My Server is local.  I tried to use restore database and it appear to be very quick.  Since i have to be able to create multiple copy of the database source and number them, it would be more logic to make copy instead of restore.  What's wrong with it?  Do i miss an operation?  Do i use the good method?

Here is the parameters define in settings of the application.
DbPrefix is the databasename to use a source.
NextSuffix is the next number of the copy.
ServerName is the name of the server to use.
public SQLManagement ()
    {
      mServer= new Server();
      mServer.ConnectionContext.DatabaseName = Properties.Settings.Default.DBPrefix;
      mServer.ConnectionContext.AutoDisconnectMode = AutoDisconnectMode.NoAutoDisconnect;
      mServer.ConnectionContext.BatchSeparator = "GO";
      mServer.ConnectionContext.ServerInstance = Properties.Settings.Default.ServerName;
      mServer.ConnectionContext.SqlExecutionModes = SqlExecutionModes.ExecuteAndCaptureSql;
      mServer.ConnectionContext.ConnectTimeout = 5;
      mServer.ConnectionContext.LoginSecure = true;
      mServer.ConnectionContext.Connect();
    }
 
    public void CreateCopy()
    {
      // Crée la base de données de destination
      Database dbSrc = mServer.Databases[Properties.Settings.Default.DBPrefix];
      Database dbDst = new Database( mServer, Properties.Settings.Default.DBPrefix + Properties.Settings.Default.NextSuffix.ToString());
 
      dbDst.Create();
 
      // Setup transfer(All objects Data and Schema)
      Transfer t = new Transfer(dbSrc);
 
      t.CopyAllTables = true;
      t.Options.WithDependencies = true;
      t.Options.ContinueScriptingOnError = true;
      t.DestinationDatabase = dbDst.Name;
      t.DestinationServer = mServer.Name;
      t.DestinationLoginSecure = true;
      t.CopySchema = true;
      t.CopyData = true;
      t.TransferData();
    }

Open in new window

LVL 4
SolutionsCSAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David ToddSenior DBACommented:
Hi,

I just saw this question get answered, and thought that the info in it might help.

Cheers
  David
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SolutionsCSAuthor Commented:
I got an alternative solutions effectively, but it's still does not explain why it is slow and if there is a way to optimize it?  35 minute on my last try with TransferData over a database of approximatively 200 megs...  In the sql 2005 wizard it take 20 seconds????  The goal of this is to produce an environment of Unitary test for software.  Any other comment or idea would be of great help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.