DBInvador/DBHandler/SQLServerHandler.cs
/// <summary>
/// Get All Tables available in a Database
/// </summary>
/// <returns>List of Schema Qualified name of all the Tables</returns>
Get All Tables available in a Database
Get All Tables available in a Database
public IEnumerable<string> GetTables(string database)
        {
            ConnectServer();
            ChangeDatabase(database);
            List<string> result = new List<string>();
            using (SqlCommand cmd = new SqlCommand("select '['+S.name + '].[' +T.name+']' as name from sys.tables T inner join sys.schemas S on T.schema_id = S.schema_id order by name", conn))
            {
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    result.Add(reader["name"].ToString());
                }
                conn.Close();
            }
            return result;
        }
public IEnumerable < string > GetTables ( string database ) { ConnectServer ( ) ; ChangeDatabase ( database ) ; List < string > result = new List < string > ( ) ; using ( SqlCommand cmd = new SqlCommand ( " " , conn ) ) { SqlDataReader reader = cmd . ExecuteReader ( ) ; while ( reader . Read ( ) ) { result . Add ( reader [ " " ] . ToString ( ) ) ; } conn . Close ( ) ; } return result ; }
Get All Tables available in a Database
Get All Tables available in a Database
List of Schema Qualified name of all the Tables
List of Schema Qualified name of all the Tables
database
string