Вы можете вызвать хранимую процедуру sp_columns для получения этой информации и других:
SqlConnection sqlConx = new SqlConnection(p_conectionStrWithDB);
sqlConx.Open();
SqlCommand cmd = new SqlCommand("sp_columns", sqlConx);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@table_name", TableName));
DataTable tblColumns = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(tblColumns);
Редактировать: Вы также можете получить информацию о первичных ключах, как это:
SqlConnection sqlConx = new SqlConnection(p_conectionStrWithDB);
sqlConx.Open();
SqlCommand cmd = new SqlCommand("sp_pkeys", sqlConx);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@table_name", tableName));
DataTable tblConstraints = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(tblConstraints);
return tblConstraints;