SQL Server 2005: Words are lost when copying table structure to another database "CONSTRAINT"

Fragment of the original table:

CREATE TABLE [dbo].[Batch](
    [CustomerDepositMade] [money] NOT NULL 
         CONSTRAINT [DF_Batch_CustomerDepositMade]  DEFAULT (0)

      

Fragment of the copied table:

CREATE TABLE [dbo].[Batch](
    [CustomerDepositMade] [money] NOT NULL,

      

Code for copy database:

        Server server = new Server(SourceSQLServer);
        Database database = server.Databases[SourceDatabase];

        Transfer transfer = new Transfer(database);
        transfer.CopyAllObjects = true;
        transfer.CopySchema = true;
        transfer.CopyData = false;

        transfer.DropDestinationObjectsFirst = true;

        transfer.DestinationServer = DestinationSQLServer;
        transfer.CreateTargetDatabase = true;

        Database ddatabase = new Database(server, DestinationDatabase);
        ddatabase.Create();
        transfer.DestinationDatabase = DestinationDatabase;
        transfer.Options.IncludeIfNotExists = true;
        transfer.TransferData();

      

+2


a source to share


1 answer


The Transfer.Options property may provide an answer. Specifically, looking at the documentation , you can set the DriDefaults property, and more generally, the DriAll property, to true.



+2


a source







All Articles