using System; using System.Data; using System.Data.SqlClient; public class GetSchema { public static void Main() { string connectionString = "Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI"; string SQL = "SELECT * FROM CUSTOMERS"; SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand(SQL, con); SqlDataReader r; DataTable schema; con.Open(); r = cmd.ExecuteReader(); schema = r.GetSchemaTable(); con.Close(); foreach (DataRow row in schema.Rows) { foreach (DataColumn col in schema.Columns) { Console.WriteLine(col.ColumnName + " = " + row[col]); } } } }