0

SMOを使用してパーティションテーブルのコピーを複製しようとしています。

using (var scope = new TransactionScope()) 
{ 
    var copiedtable = CreateTable(sourcetable);

    createColumns(sourcetable, copiedtable);
    CreateIndexes(sourcetable, copiedtable);
    CreateForeignKeys(sourcetable, copiedtable);

    sourcetable.PartitionScheme = sourcetable.PartitionScheme + "1";

    scope.Complete();
    return copiedtable; 
 } 

コピーは作成されますが、パーティションスキームは無視されます。パーティションスキームに合わせる方法はありますか?私は物事を間違った方法で行っていますか?エラーメッセージや例外が表示されないので、コードはパーティション化されたテーブルのパーティション化されていないコピーをサイレントに作成します。

パーティションが間違ったスキーマに配置されているテーブルが数百あるので、自動化したいと思います。

4

1 に答える 1

0

定義を StringBuilder にスクリプト化し、検索と置換を行うことで回避策を見つけました。

        var scriptOptions = new ScriptingOptions
                                {
                                    ClusteredIndexes = true,
                                    Default = true,
                                    FullTextIndexes=true,
                                    Indexes=true,
                                    NonClusteredIndexes = true,
                                    SchemaQualify = true,
                                    DriAllConstraints = true
                                };

        var tableScripts = table.Script(scriptOptions);
        String indexName = null;

        // Adjust to new table name
        sb.Replace(tableName, tableNameNew);

        //
        sb.Replace(partitionName, partitionName + "_New")
于 2012-11-08T15:40:22.577 に答える