Hello,
We're trying to transfer database from SQL 2005 to SQL 2008 with following code-
Server
srcSrv = new Server("einpxp102\\sqlexpress");
Server dstSrv = new Server("einpxp102");
// Get source database from the source server.
Database srcDb = srcSrv.Databases[srcDatabaseName];
// Create backup databse on the destination server
Database dstDb = new Database(dstSrv, dstDatabaseName);
dstDb.Create();
// This creates the new database on the 'destination' server.
// Create transfer.
Transfer t = new Transfer(srcDb);
t.CopyAllObjects =
true;
t.CopySchema =
true;
t.CopyData =
true;
// Set the destination table for the transfer object.
t.DestinationDatabase = dstDb.Name;
// Now set up the destination server
t.DestinationServer = dstSrv.Name;
// and to the transfer, this should do it.
t.TransferData();
But it is not transferring primary keys and foreign keys. I'd appreciate any help on it.
Regards,
Gurmit