public string SqlStatement() { string result = DatabaseUnusedIndexes.SqlStatement(); return(result); // TODO: add assertions to method DatabaseUnusedIndexesTest.SqlStatement() }
/// <summary> /// Gets the database changes in the last 90 days. /// </summary> /// <param name="database">The database.</param> /// <returns>the database changes in the last 90 days.</returns> public List <DatabaseUnusedIndexes> GetDatabaseUnusedIndexes(string database) { this.ExecuteUseDatabase(database); List <DatabaseUnusedIndexes> results = new List <DatabaseUnusedIndexes>(); DatabaseUnusedIndexes resultrow; string sqlString = DatabaseUnusedIndexes.SqlStatement(); sqlString = string.Format("EXEC sp_executesql @statement = N'{0}'", sqlString.Replace("'", "''")); using (SqlConnection connection = new SqlConnection(this.ConnectionString)) using (SqlCommand command = new SqlCommand(sqlString, connection)) { connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { resultrow = new DatabaseUnusedIndexes( reader.GetString(reader.GetOrdinal("Schema")), reader.GetString(reader.GetOrdinal("Table")), reader.GetString(reader.GetOrdinal("Index"))); results.Add(resultrow); } } connection.Close(); } return(results); }