Beispiel #1
0
        //private string Clean(string cleanthis, string table, string nameparameter, string datatype)
        //{
        //    return new StringBuilder(cleanthis)
        //          .Replace("%TABLE%", table)
        //          .Replace("%PRIME%", nameparameter)
        //          .Replace("%TYPE%", datatype)
        //          .ToString();
        //}

        public void ForTable()
        {
            if (!IfExists(tableName))
            {
                var sql         = $@"CREATE TABLE {tableName} ([Id] INT IDENTITY (1, 1) NOT NULL, PRIMARY KEY CLUSTERED ([Id] ASC));";
                var handlerBase = new SQLHandlerBase();
                handlerBase.DoQueryNonScaler(sql);
            }
        }
Beispiel #2
0
 public void ForIndex(string indexColumn)
 {
     if (!IfIndexExists(tableName, indexColumn))
     {
         var sql = $"CREATE UNIQUE NONCLUSTERED INDEX [ix{tableName}_{indexColumn}] " +
                   " ON [dbo].[CIM_{tableName}]([{indexColumn}] ASC);";
         var handlerBase = new SQLHandlerBase();
         handlerBase.DoQueryNonScaler(sql);
     }
 }
Beispiel #3
0
 public void ForColumn(string columnName, string datatype, bool nullable, bool indexed)
 {
     if (!IfColumnExists(tableName, columnName))
     {
         var nullvalue   = nullable ? "NULL" : "";
         var sql         = $"Alter Table {tableName} Add Column {columnName} {nullvalue}";
         var handlerBase = new SQLHandlerBase();
         handlerBase.DoQueryNonScaler(sql);
         if (indexed)
         {
             ForIndex(columnName);
         }
     }
 }
Beispiel #4
0
        public void ForIndex(string indexColumn)
        {
            var ixName = ("ix" + tableName + '_' + indexColumn).Replace('[', '_').Replace(']', '_');

            //if (!IfIndexExists(tableName, indexColumn))
            if (!IfIndexExists(tableName, ixName))
            {
                //var sql = $"CREATE UNIQUE NONCLUSTERED INDEX [ix{tableName}_{indexColumn}] " +
                //           $" ON [dbo].[CIM_{tableName}]([{indexColumn}] ASC);";
                var sql = $"CREATE UNIQUE NONCLUSTERED INDEX [{ixName}] " +
                          $" ON {tableName} ({indexColumn} ASC);";
                var handlerBase = new SQLHandlerBase();
                handlerBase.DoQueryNonScaler(sql);
            }
        }