Example #1
0
    public static void CopyTableStructure(SqlTableReference sourceTable, SqlTableReference targetTable)
    {
        var sisTable          = InformationSchemaMetadataExplorer.GetInformationSchemaTableDefinition(sourceTable);
        var createTableScript = SISToSqlDmlCreateStatementGenerator.GenerateCreateTableScript(sisTable);

        targetTable.SqlConnectionProvider.Execute(createTableScript);
    }
    public void TestSampleCreateTableScript()
    {
        var tableDefinition = InformationSchemaTableDefinitionFromJson.SampleTable();
        var script          = SISToSqlDmlCreateStatementGenerator.GenerateCreateTableScript(tableDefinition);

        Console.WriteLine(script);
    }
Example #3
0
    public void CreateIfTests()
    {
        var tableDef           = InformationSchemaTableDefinitionFromJson.SampleTable();
        var createAnywayScript =
            SISToSqlDmlCreateStatementGenerator.GenerateCreateTableScript(
                tableDef, CreateIfExistsModification.CreateAnyway);

        var dropAndRecreateScript =
            SISToSqlDmlCreateStatementGenerator.GenerateCreateTableScript(
                tableDef, CreateIfExistsModification.DropAndRecreate);

        var createOnlyIfNotExistsScript =
            SISToSqlDmlCreateStatementGenerator.GenerateCreateTableScript(
                tableDef, CreateIfExistsModification.CreateIfNotExists);

        Console.WriteLine(createAnywayScript);
        Console.WriteLine(dropAndRecreateScript);
        Console.WriteLine(createOnlyIfNotExistsScript);
    }