Example #1
0
        public static void CreateEmpty(string catalog)
        {
            var datasource = new SqlConnectionStringBuilder(Config.Settings.ConnectionString).DataSource;

            Log.i("DB", $"Creating database \'{catalog}\' in \'{datasource}\'.");
            MasterDatabase.Execute($"CREATE DATABASE {catalog}");
        }
Example #2
0
 static void Drop(string catalog)
 {
     Log.i("DB", "Dropping database '" + catalog + "'.");
     MasterDatabase.Execute($@"WHILE EXISTS(select NULL from sys.databases where name='{catalog}')
         BEGIN
             DECLARE @SQL varchar(max)
             SELECT @SQL = COALESCE(@SQL,'') + 'Kill ' + Convert(varchar, SPId) + ';'
             FROM MASTER..SysProcesses WHERE DBId = DB_ID(N'{catalog}') AND SPId <> @@SPId
             EXEC(@SQL)
             DROP DATABASE [{catalog}]
         END");
 }