SQL Server 2005: Quando copiare la struttura delle tabelle di altri database “costrizione” parole chiave persa

StackOverflow https://stackoverflow.com/questions/2724712

Domanda

Snippet di tabella originale:

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

Snippet di tabella copiata:

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

Codice per il database di copia:

        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();
È stato utile?

Soluzione

La proprietà Transfer.Options può fornire una risposta. In particolare, guardando il documentazione , impostando la proprietà DriDefaults e, più in generale, la proprietà DriAll true aiuto maggio.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top