public static string DropIndex(SysIndex index) { return(string.Join("\n", new string[] { $"IF EXISTS (SELECT * FROM sys.indexes WHERE name = '{index.name}' and object_id = OBJECT_ID('{index.qualified_table_name}'))", $"DROP INDEX [{index.name}] ON {index.qualified_table_name}\n", })); }
public static string CreateIndex(SysIndex index) { return(string.Join("\n", new string[] { $"IF NOT EXISTS (SELECT * FROM sys.indexes WHERE name = '{index.name}' and object_id = OBJECT_ID('{index.qualified_table_name}'))", $"CREATE {index.type_desc} INDEX [{index.name}] ON {index.qualified_table_name} {index.columns}", (index.include == null? "": $"INCLUDE {index.include}\n") + BatchSeperator })); }