Ejemplo n.º 1
0
        internal static string CreateDatabaseExistsScript(string databaseName)
        {
            var builder = new DdlBuilder();

            builder.AppendSql("SELECT Count(*) FROM ");
            builder.AppendSql("sys.databases");
            builder.AppendSql(" WHERE [name]=");
            builder.AppendStringLiteral(databaseName);
            return(builder.stringBuilder.ToString());
        }
Ejemplo n.º 2
0
        internal static string CreateDatabaseScript(string databaseName, string dataFileName, string logFileName)
        {
            var builder = new DdlBuilder();

            builder.AppendSql("create database ");
            builder.AppendIdentifier(databaseName);
            if (null != dataFileName)
            {
                builder.AppendSql(" on primary ");
                builder.AppendFileName(dataFileName);
                builder.AppendSql(" log on ");
                builder.AppendFileName(logFileName);
            }
            return(builder.stringBuilder.ToString());
        }
Ejemplo n.º 3
0
        internal static string DropDatabaseScript(string databaseName)
        {
            var builder = new DdlBuilder();

            builder.AppendSql("drop database ");
            builder.AppendIdentifier(databaseName);
            return(builder.stringBuilder.ToString());
        }
Ejemplo n.º 4
0
        private void AppendCreateSchema(string schema)
        {
            AppendSql("if (schema_id(");
            AppendStringLiteral(schema);
            AppendSql(") is null) exec(");

            // need to create a sub-command and escape it as a string literal as well...
            DdlBuilder schemaBuilder = new DdlBuilder();

            schemaBuilder.AppendSql("create schema ");
            schemaBuilder.AppendIdentifier(schema);

            AppendStringLiteral(schemaBuilder.stringBuilder.ToString());
            AppendSql(");");
            AppendNewLine();
        }